1. Go to this page and download the library: Download thesis/hot-reload 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/ */
thesis / hot-reload example snippets
use Amp\Cancellation;
use Amp\Http\Server\SocketHttpServer;
use function Amp\ByteStream\getStdout;
use function Amp\trapSignal;
use function Thesis\hotReload;
hotReload(
files: __DIR__,
task: static function (Cancellation $termination): void {
$server = SocketHttpServer::createForDirectAccess(/** ... */);
$termination->subscribe($server->stop(...));
$server->expose(/** ... */);
$server->start(/** ... */);
trapSignal([SIGINT, SIGTERM], cancellation: $termination);
$server->stop();
},
onReload: static function (): void {
getStdout()->write("\nFiles changed, reloading server...\n\n");
},
);
bash
# Watch src/, restart on any file change
vendor/bin/hot-reload -- php server.php
# Watch multiple paths, only .php files
vendor/bin/hot-reload --path=src --path=config --ext=php -- php server.php
# Exclude generated files
vendor/bin/hot-reload --path=src --ext=php --exclude='*.generated.php' -- php server.php
# Increase debounce delay (useful when many files change at once)
vendor/bin/hot-reload --debounce=0.5 -- php server.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.