Skip to content

nexphant/dev ​

Development-only file watcher with automatic process restarting for live reloading.

Install ​

bash
composer require nexphant/dev --dev

Usage ​

bash
php nexphant.dev.php

Or via composer:

bash
composer run dev

Configuration ​

The dev reloading configuration is defined in a php script, typically nexphant.dev.php:

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)        // shutdown timeout in seconds
    ->run();

CLI Hot Reloading API ​

MethodReturn TypeDescription
watch(array $paths)selfPaths to watch for modifications, creations, or deletions.
ignore(array $paths)selfPaths to exclude from file watching.
ext(array $extensions)selfSpecific file extensions to monitor (e.g. ['php', 'json']).
command(string $command)selfCommand to execute and reload.
delay(int $ms)selfDebounce time in milliseconds between changes and restart.
gracefulTimeout(float $seconds)selfMaximum time to wait for worker process to terminate after sending SIGTERM.
root(string $root)selfThe base project path.
run()voidStarts the file watcher snapshot and runner loop.

Released under the MIT License.