A Laravel package that provides file watching functionality to automatically execute a CLI or Artisan command when files change. This is useful for automatically running tests, linting, or any other command when your files are modified during development.
Warning
Very early alpha — pure proof of concept.
Believe it or not, ~95% of this package’s code is AI-generated under 10 minutes with a single prompt!
For the full story, check out the PR.
You can install the package via composer:
composer require plakhin/laravel-artisan-watcher --devThe package adds an artisan watch command that you can use to watch for file changes and trigger commands:
# Watch current directory and run tests when PHP files change
php artisan watch --command="php artisan test"
# Watch a specific directory for changes to JS files
php artisan watch app/Http --extensions=js --command="npm run lint"
# Watch with custom polling interval (in seconds)
php artisan watch --interval=2 --command="php artisan test"
# Exclude multiple directories
php artisan watch --exclude=vendor,node_modules,storage --command="php artisan test"path: The directory to watch (default: current directory)--command: The command to run when files change (required)--interval: Polling interval in seconds (default: 1)--extensions: Comma-separated list of file extensions to watch (default: php)--exclude: Comma-separated list of directories to exclude (default: vendor,node_modules)
-
Automatically run tests when files change:
php artisan watch --command="php artisan test" -
Automatically compile assets when JavaScript or SCSS files change:
php artisan watch resources --extensions=js,scss --command="npm run dev" -
Run type checking when PHP files change:
php artisan watch --command="php artisan test:types"
Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests.
- Fork the project
- Create a new branch
- Code, test, commit and push
- Open a pull request detailing your changes.
- Please ensure the coding style running
composer lint. - Please keep the codebase modernized using automated refactors with Rector
composer refactor. - Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
- You may need to rebase to avoid merge conflicts.
- Please remember to follow SemVer.
composer lintcomposer refactorRun all tests:
composer testCheck code style:
composer test:lintCheck possible code improvements:
composer test:refactorCheck types:
composer test:typesRun Unit tests:
composer test:unitPlease see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.