当更新完代码后,每次都得重启,效率比较低

可以使用官方的热更新包,实现修改代码后,自动重启

 

如果是新版本安装

composer require hyperf/watcher --dev

 

如果是使用旧的版本可以直接在composer.json  require-dev中添加

比如2.1.*

"hyperf/watcher": "~2.1.0"

 

发布配置:

php bin/hyperf.php vendor:publish hyperf/watcher

 

配置文件是这样的config/autoload/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,
    ],
];

 

使用这句命令启动

php bin/hyperf.php server:watch

更改代码后,会自动重启

[PHP] hyperf框架代码热更新

 

相关文章:

  • 2022-12-23
  • 2021-06-25
  • 2021-05-20
  • 2021-09-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
  • 2021-12-17
  • 2021-11-10
  • 2021-11-20
相关资源
相似解决方案