Skip to content

About

Restart a development server on file changes or SIGHUP, including after a failed launch.

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Thesis Hot Reload

PHP Release License PHPStan Coverage

This read-only repository mirrors packages/hot-reload. Open issues and pull requests in the thesis-php/thesis monorepo.

Report a bug · Request a feature · Changelog · Contributing

Run a development server under hot-reload. Use --watch to restart the server when files change, even after it crashes. Requires PHP 8.6 on Unix with ext-pcntl.

composer require --dev thesis/hot-reload:^0.5
vendor/bin/hot-reload --watch server.php --watch src -- php server.php

Pass --watch once per file or directory to monitor. The paths must exist when the command starts. The watcher checks file names and contents every 200 ms. Directories are scanned recursively and symlinks inside them are skipped. Watch the source and configuration paths you edit to keep the scans small.

Use --debounce 350ms or --debounce=1.5s to set how long the watcher waits after the last detected edit. The default is 200ms. Before requesting a restart the watcher checks for new edits again. Use --debounce 0 to request a restart as soon as a poll detects a change. SIGHUP always requests a restart immediately.

For an immediate restart request, send kill -HUP <pid> to the supervisor PID printed at startup. You can omit --watch to use manual restarts only. The server inherits stdio, so startup errors and application logs appear in the same terminal. If the server exits, the supervisor reports its exit status and waits for a file change or SIGHUP.

The server shares the supervisor's terminal and process group, so interactive commands can open /dev/tty. Ctrl+C sends SIGINT to both processes. The supervisor waits for the server to finish. Ctrl+\ works the same way with SIGQUIT. Use kill -TERM <pid> to stop the supervisor from a script: it forwards SIGTERM to the server. With a controlling terminal, sending SIGINT only to the supervisor starts the wait without signalling the server. Without a controlling terminal, the supervisor forwards SIGINT and SIGQUIT.

A restart sends SIGTERM. On restart or shutdown, a server still running after three seconds receives SIGKILL. The replacement starts after the old server exits. Saves during shutdown go into that same replacement.

About

Restart a development server on file changes or SIGHUP, including after a failed launch.

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from thesis-php/template