Dev Reload
Nexphant includes a built-in file watcher that restarts your application process oa-claude-sonnet-4.6matically when files change. No external tools needed.
Setup
nexphant.dev.php at project root:
php
<?php
require __DIR__ . '/vendor/autoload.php';
use Nexphant\Dev\Reload;
Reload::watch(['app/', 'config/', 'routes/'])
->ignore(['storage/', 'vendor/', '.git/'])
->ext(['php', 'env', 'json'])
->command('php app.php')
->delay(300) // debounce delay in ms
->gracefulTimeout(5.0) // wait for process to stop cleanly
->run();Run
bash
php nexphant.dev.phpOr via Composer script:
bash
composer run devOptions
| Method | Description |
|---|---|
watch(array $paths) | Directories to monitor for changes. |
ignore(array $paths) | Directories to exclude from watching. |
ext(array $extensions) | File extensions to watch (default: php). |
command(string $cmd) | Command to run and restart. |
delay(int $ms) | Debounce delay between a file change and restart (ms). |
gracefulTimeout(float $s) | Seconds to wait for the process to exit after SIGTERM before force-killing. |
root(string $path) | Base path for resolving watch directories. |
How It Works
- On start, a snapshot of all watched files is taken.
- Each poll interval, file mtimes are compared to the snapshot.
- On any change,
SIGTERMis sent to the running process. - After
gracefulTimeout, the process is force-killed if still running. - The command is restarted and a new snapshot is taken.
Crashes are handled — the process restarts automatically after a configurable delay.
