PHP code example of vajexal / hot-reload

1. Go to this page and download the library: Download vajexal/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/ */

    

vajexal / hot-reload example snippets




mp\Http\Server\HttpServer;
use Amp\Http\Server\RequestHandler\CallableRequestHandler;
use Amp\Http\Server\Response;
use Amp\Http\Status;
use Amp\Loop;
use Amp\Socket;
use Psr\Log\NullLogger;

Loop::run(static function () {
    $servers = [
        Socket\Server::listen('0.0.0.0:1337'),
    ];

    $server = new HttpServer($servers, new CallableRequestHandler(static function () {
        return new Response(Status::OK, [], 'Hello World');
    }), new NullLogger);

    yield $server->start();
});
bash
./vendor/bin/hot-reload server.php
bash
watchman watch $(pwd)
watchman -- trigger $(pwd) hot-reload '*.php' -- php server.php
bash
ls *.php | entr -r php server.php