Skip to content

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.php

Or via Composer script:

bash
composer run dev

Options ​

MethodDescription
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 ​

  1. On start, a snapshot of all watched files is taken.
  2. Each poll interval, file mtimes are compared to the snapshot.
  3. On any change, SIGTERM is sent to the running process.
  4. After gracefulTimeout, the process is force-killed if still running.
  5. The command is restarted and a new snapshot is taken.

Crashes are handled — the process restarts automatically after a configurable delay.

Next Steps ​

Released under the MIT License.