plakhin/laravel-artisan-watcher
Composer 安装命令:
composer require plakhin/laravel-artisan-watcher
包简介
A Laravel Artisan package to watch for file changes and automatically execute commands
README 文档
README
Laravel Artisan Watcher
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.
Installation
You can install the package via composer:
composer require plakhin/laravel-artisan-watcher --dev
Usage
The 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"
Available Options
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)
Example Use Cases
-
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"
Contributing
Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests.
Process
- Fork the project
- Create a new branch
- Code, test, commit and push
- Open a pull request detailing your changes.
Guidelines
- 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.
Linting
composer lint
Refactoring with Rector
composer refactor
Testing
Run all tests:
composer test
Check code style:
composer test:lint
Check possible code improvements:
composer test:refactor
Check types:
composer test:types
Run Unit tests:
composer test:unit
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-26