PHP directory watch script inspired by remy/nodemon
Inspired by nodemon. For use during development of a PHP based application.
Pharmon will watch the files in the directory in which Pharmon was started, and if any files change, Pharmon will automatically restart your PHP application.
Warning current release uses
to execute commands.
Globally installing Pharmon.
composer global require enom/pharmon
You will need to add Composer's bin directory to your PATH in
~/.bashrc) by adding the following line:
Watches directories and runs commands on file changes.
pharmon # Runs `php index.php` and watches the current directory
Useful for linting and testing. You can specify one or more directories to
watch by using the
-w flag and one or more commands to execute with the
pharmon -w src/ -w tests/ -x 'composer run test' # Runs `composer run test` and watches the specified directories
You can also get the absolute file path that triggered the change using
your command string:
pharmon -w src/ -x 'composer run lint:file @' # Runs (e.g.) `composer run lint:file /var/www/pharmon/src/Pharmon/Watcher.php`
@ symbol can be escaped in your command string which will prevent the
replacement from hapening:
pharmon -w dist/ -e js,css -x 'scp @ deploy\@env.host:@' # Runs (e.g.) `scp /var/www/dist/app.js firstname.lastname@example.org:/var/www/dist/app.js`
PHP doesn't come with multithreading support enabled by default so there's no way to listen for both filesystem events and manual restarts(#9).
Please make sure
composer run standard and
composer run test are both
passing before pushing.