Skip to content

Dev Reload ​

Automatic process restart on file change.

Setup ​

nexphant.dev.php:

php
use Nexphant\Dev\Reload;

Reload::create()
    ->watch(['app/', 'config/', 'routes/'])
    ->ignore(['storage/', 'vendor/'])
    ->run('php app.php');

Start ​

bash
composer run dev

Output:

[nexphant] dev reload started
[nexphant] watching: app/, config/, routes/
[nexphant] running: php app.php

Edit a File ​

Open app/Controllers/HomeController.php and save a change.

Output:

[nexphant] change detected: app/Controllers/HomeController.php
[nexphant] stopping process...
[nexphant] restarting: php app.php
[nexphant] running: php app.php

Restart Output ​

Full restart sequence:

  1. File change detected
  2. SIGTERM sent to process
  3. Process stops (graceful)
  4. New process starts
  5. Ready to accept requests

Crash Handling ​

If the process exits with an error:

[nexphant] process exited with code 255
[nexphant] stderr: PHP Fatal error: ...
[nexphant] waiting 1s before restart...
[nexphant] restarting: php app.php

Notes ​

  • Dev reload polls every 500ms by default
  • Not for production use
  • Use composer run start (php app.php) for production

Released under the MIT License.