1. Go to this page and download the library: Download phprtc/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/ */
phprtc / watcher example snippets
use RTC\Watcher\Watcher;
use RTC\Watcher\Watching\EventInfo;
ath(__DIR__ . '/views')
->onChange(function (EventInfo $eventInfo) {
echo $eventInfo->getWatchedItem()->getFullPath() . PHP_EOL;
})
->watch();
use RTC\Watcher\Watcher;
use RTC\Watcher\Watching\EventInfo;
y(function (EventInfo $eventInfo) {
echo date('H:i:s') . " - {$eventInfo->getName()} {$eventInfo->getWatchedItem()->getFullPath()}\n";
})
->watch();
use RTC\Watcher\Watcher;
use RTC\Watcher\Watching\EventInfo;
re(__DIR__ . '/test1/t/*') // Ignore files in "/test1/t/"
->ignore([
__DIR__ . '/test1/t/.*(\.php$)', // Ignore files that end with "php" in "/test1/t/"
__DIR__ . '/test1/t/.*(\.js)', // Ignore files that end with "js" in "/test1/t/"
])
->onChange(function (EventInfo $eventInfo) {
echo date('H:i:s') . " - {$eventInfo->getName()} {$eventInfo->getWatchedItem()->getFullPath()}\n";
})
->watch();
use RTC\Watcher\Watcher;
use RTC\Watcher\Watching\EventInfo;
ShouldNotEndWith(['.php'])
->onChange(function (EventInfo $eventInfo) {
echo $eventInfo->getWatchedItem()->getFullPath() . PHP_EOL;
})
->watch();
use RTC\Watcher\Watcher;
use RTC\Watcher\Watching\EventInfo;
xtension('php')
->onChange(function (EventInfo $eventInfo) {
echo $eventInfo->getWatchedItem()->getFullPath() . PHP_EOL;
})
->watch();
use RTC\Watcher\Watcher;
use RTC\Watcher\Watching\EventInfo;
use Swoole\Timer;
entInfo $eventInfo) {
echo date('H:i:s') . ": CREATED - {$eventInfo->getWatchedItem()->getFullPath()}\n";
});
Timer::after(1000, fn() => $watcher->stop()); // Stop watching after 1 second
$watcher->start();
touch(__DIR__ . '/auto-created.txt');
unlink(__DIR__ . '/auto-created.txt');
use Swoole\Http\Request;
use Swoole\Http\Response;
use Swoole\Http\Server;
use RTC\Watcher\Watcher;
$response) {
$response->end('Hello world');
});
$server->on('start', function (Server $server) {
echo "Server started at http://0.0.0.0:9000\n";
Watcher::create()
->addPath(__DIR__ . '/app')
->addPath(__DIR__ . '/views')
->onChange(fn() => $server->reload())
->watch();
});
$server->start();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.