Swoole version:1.9.6
In fact, it is not related to the version of Swoole, because the original code system, FPM mode, at startup, the use of the CHDIR function to change the current directory, and other code in the automatic loading of classes, are written relative to the address, not the absolute address.
The problem is, Swoole is multi-process, in daemonize mode, chdir change the current directory, in other processes is not effective, so sometimes, do not use daemonize no problem, and use daemonize will be inexplicable to find the case of the class.
The workaround is to change the directory at the same time in a few startup callbacks
$serv->on ( ' workstart ', function ($server, $FD) { chdir (root_path);//Assuming that the Root_path constant has been set in the preceding /other Code }); $serv->on ( ' tast ', function ($server, $FD) { chdir (root_path);//Assuming that the Root_path constant has been set earlier// other code
Related article: http://hongtoushizi.iteye.com/blog/2224764
Has fun with swoole!
[PHP] Swoole in daemonize mode, chdir failure problem