robert-grubb/php-hotreload

用于通过CLI保持活跃的脚本的即时重载。

v1.0.4 2024-01-10 21:24 UTC

This package is not auto-updated.

Last update: 2024-09-19 19:43:02 UTC


README

这是一个简单的包,允许您通过CLI命令(守护进程)实时重载脚本。例如,如果您在脚本中运行一个无限while循环,并且不希望每次更改时都停止和重新启动,那么这个包非常适合您。

致谢

感谢包 felippe-regazio/php-hot-reloader 提供了一种检查目录和文件更改的出色方式。

安装

composer require robert-grubb/php-hotreload

使用方法

require_once __DIR__ . '/vendor/autoload.php';

/**
 * Instantiates new HotReloader and listens for changes the directory
 * specified except for the ignored directory.
 */
$hotReloader = new HotReload\Instance([
    'entryFile' => __DIR__ . '/test.php', // Entry file to run command
    'entryArguments' => false, // String of arguments for entry (ex. --foo=bar)
    'rootDirectory' => __DIR__, // The root directory
    'watch' => [ '.' ], // List of files/directories to watch (Relative path to root)
    'ignore' => [ 'ignored' ] // List of files/directories to ignore (Relative path to root)
]);

/**
 * Start the reload watcher
 */
$hotReloader->startWatcher();

预览