1、安装 composer require hyperf/watcher
2、生成配置文件 php bin/hyperf.php vendor:publish hyperf/watcher
3、生成后的文件在 根目录下的 .watcher.php
代码就是
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\Watcher\Driver\ScanFileDriver;
return [
'driver' => ScanFileDriver::class,
'bin' => 'php',
'watch' => [
'dir' => ['app', 'config'],
'file' => ['.env'],
'scan_interval' => 2000,
],
];
image.png
4、查询当前还在运行的pid 不看也行
netstat -anp|grep 9501
kill 上边儿的pid
5、执行启动
php bin/hyperf.php server:watch
end.