nano
nano copied to clipboard
热更新不可用
热更新不可用 php index.php server:watch Generating optimized autoload files Generated optimized autoload files containing 1087 classes
Start server ... PHP Warning: require_once(bin/hyperf.php): Failed to open stream: No such file or directory in /data/docker/fastdeploy/vendor/hyperf/watcher/watcher.php on line 31 PHP Fatal error: Uncaught Error: Failed opening required 'bin/hyperf.php' (include_path='.:/usr/share/php') in /data/docker/fastdeploy/vendor/hyperf/watcher/watcher.php:31 Stack trace: #0 {main} thrown in /data/docker/fastdeploy/vendor/hyperf/watcher/watcher.php on line 31 Stop server success.
尝试把 vendor/hyperf/watcher/watcher.php 中的 bin/hyperf.php 修改为index.php后, 能正常启动, 但修改index.php后无法热更新
I have the same problem. How do you use hot reload with nano?
@devaex Now I use nodemon to hot reload
npm install -g nodemon
create nodemon.json
file in project
{
"watch": [
"index.php"
],
"exec": "php index.php start",
"signal": "SIGINT"
}
then run nodemon
Thanks. This worked.
As a suggestion, the watcher should be included in nano. It is something very basic and essential for development.
As it has a dependency on bin/hyperf.php there is no way to use it outside of the main framework.
Another solution that does not depend on node.
#!/bin/bash
exitfn () {
kill $PID
echo; echo "Exiting and killing process $PID"
exit
}
# to handle ctrl+c for forced finalization
trap "exitfn" INT
while true
do
php app/server.php start & PID=$!
echo "Process cretated: $PID"
inotifywait -e modify,create,delete -r ./app
echo "Killing process $PID"
kill $PID
done
sudo apt install inotify-tools
to install inotify