vajexal / hot-reload
Hot reload php scripts
0.1.0
2021-05-26 16:55 UTC
Requires
- php: ^7.4|^8.0
- ext-mbstring: *
- ext-pcntl: *
- amphp/amp: ^2.5
- amphp/byte-stream: ^1.8
- amphp/file: ^1.0
- amphp/process: ^1.1
- symfony/polyfill-php80: ^1.22
Requires (Dev)
- ext-eio: *
- ext-uv: *
- amphp/http-client: ^4.5
- amphp/http-server: ^2.1
- amphp/log: ^1.1
- amphp/php-cs-fixer-config: dev-master#e8930dcb166f4bcbc8bd3c37e5535bd8960ffea9
- amphp/phpunit-util: ^1.4
- symfony/console: ^5.1
This package is auto-updated.
Last update: 2025-03-27 01:43:17 UTC
README
Attempt to make hot reloading for php scripts (Amp for example)
Installation
composer require --dev vajexal/hot-reload
Usage
Amp server for example
server.php
<?php require_once 'vendor/autoload.php'; use Amp\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(); });
./vendor/bin/hot-reload server.php
Now you can modify server.php
and see changes without restarting the script
Alternatives
watchman watch $(pwd) watchman -- trigger $(pwd) hot-reload '*.php' -- php server.php
ls *.php | entr -r php server.php
Notes
- package use filesystem polling, so it will add some cpu usage
vendor
,.idea
,.git
dirs aren't watched