Automatic restart service
Swoft 2.0 removes the auto-restart feature from the built-in components and is provided by the new standalone tool swowt-cli. Help developers make the changed code take effect quickly during development.
It should be noted that 2.0 is to restart the entire service instead of reloading the work process like 1.0.
serve:run (you can also use the alias
View available options
php swoftcli.phar run -h # 如果已放到了全局PATH里，可以直接这样使用 swoftcli run -h
-b, --bin-filespecifies the entry
-b, --bin-filefor the swowt application. The default is
--intervalmonitor file interval, check by default 3 seconds
--php-binspecifies your php executable file. By default, it will automatically find php from the global path.
-c, --start-cmdspecifies the server startup command. The default is
http:start(start http server)
-w, --watchspecifies the directory to monitor, relative to the application directory. Default monitoring
app,configfile changes in
targetPath only one parameter, which specifies the directory where the swowt application to be run is located. The default is the current directory.
swoftcli run -c ws:start -b bin/swoft /path/to/php/swoft
After running successfully, you can see the following information:
Swoft-cli will automatically restart the app when there is a file change.
Warning ⚠️ When using Swoftcli to monitor server development, you cannot configure the server to run in the background. Otherwise, Swoftcli will mistakenly think that the server has quit unexpectedly, resulting in repeated startup.