hyperf热启动,热更新,更改代码自动重启

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.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容