1. Go to this page and download the library: Download ryx16/file-watcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ryx16 / file-watcher example snippets
$watchRule = new \EasySwoole\FileWatcher\WatchRule(EASYSWOOLE_ROOT."/App");
namespace EasySwoole\EasySwoole;
use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\FileWatcher\FileWatcher;
use EasySwoole\FileWatcher\WatchRule;
class EasySwooleEvent implements Event
{
public static function initialize()
{
date_default_timezone_set('Asia/Shanghai');
}
public static function mainServerCreate(EventRegister $register)
{
$watcher = new FileWatcher();
$rule = new WatchRule(EASYSWOOLE_ROOT."/App");
$watcher->addRule($rule);
$watcher->setOnChange(function (){
Logger::getInstance()->info('file change ,reload!!!');
ServerManager::getInstance()->getSwooleServer()->reload();
});
$watcher->attachServer(ServerManager::getInstance()->getSwooleServer());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.