1. Go to this page and download the library: Download cydrickn/php-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/ */
cydrickn / php-watcher example snippets
Cydrickn\PHPWatcher\Adapters\SwooleTimerAdapter;
$watcher = new \Cydrickn\PHPWatcher\Watcher(
new SwooleTimerAdapter(),
[__DIR__],
[__DIR__ . '/vendor/'],
function (array $changes) {
echo json_encode($changes) . PHP_EOL;
}
);
$watcher->tick();
namespace Your\Namespace;
use Cydrickn\PHPWatcher\Adapters\AdapterInterface;
class YourAdapter implements AdapterInterface
{
public function tick(callable $handler, int $interval = 1000)
{
// Implement your own logic
// Also make sure to call the handler to trigger the checking of changed files
// e.g. call_user_func($handler);
}
}
shell
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.