phpro/grumphp
GrumPHP is a Composer plugin that installs Git hooks to run quality checks on every commit. It executes configured tasks like tests and linters, blocks failing commits, and helps teams enforce coding standards and best practices automatically.
GrumPHP is a pre-commit Git hook framework designed to enforce code quality standards in PHP projects. It integrates seamlessly with Laravel/PHP ecosystems by:
Key Fit Areas:
laravel-pint, pest).grumphp.event_listener tags.| Aspect | Feasibility | Notes |
|---|---|---|
| Laravel Compatibility | High | Works with PHP 5.6+; Laravel 5.5+ (PHP 7.1+) fully supported. |
| Task Plugins | High | Native support for PHPUnit, Pest, PHPStan, PSR-12, etc. |
| Git Hooks | Medium | May conflict with existing hooks (backups created, but manual resolution needed). |
| CI/CD Pipelines | High | Can run as a standalone check (grumphp run) or via Git hooks. |
| Monorepos | Medium | Requires careful hooks_dir/git_hook_variables configuration. |
Critical Dependencies:
| Risk Area | Severity | Mitigation |
|---|---|---|
| Hook Conflicts | Medium | Backup existing hooks; use --no-scripts during composer install. |
| Performance Overhead | Low | Parallel execution (max_workers: 32) mitigates this. |
| Task Configuration | Medium | Steep learning curve for custom tasks; leverage Laravel’s service container. |
| CI/CD Integration | Low | Run grumphp run as a pipeline step to bypass hooks. |
| Legacy PHP Support | Low | Laravel 5.5+ requires PHP 7.1+; GrumPHP supports down to 5.6 (minor tradeoff). |
Open Questions:
APP_ENV=testing)?| Component | Compatibility | Notes |
|---|---|---|
| Laravel Framework | High | Supports all Laravel versions (PHP 7.1+). |
| Laravel Mix/Webpack | Low | No direct integration; tasks run on PHP code only. |
| Laravel Forge/Envoyer | Medium | Git hooks may conflict; prefer grumphp run in CI. |
| Pest/PHPUnit | High | Native task support. |
| Laravel Valet/Sail | High | Configure EXEC_GRUMPHP_COMMAND for containerized environments. |
| Monorepos | Medium | Requires per-repo grumphp.yml or shared config management. |
Pilot Phase:
composer require --dev phpro/grumphp).grumphp.yml with minimal tasks (e.g., phpunit, psr12).grumphp run as a pipeline step).Gradual Rollout:
phpstan, laravel-pint).parallel.enabled: true) for performance.grumphp run.Advanced Customization:
APP_ENV=production).Full Adoption:
--no-verify flags).max_workers as needed.| Scenario | Compatibility | Workaround |
|---|---|---|
| Laravel + Docker | High | Set EXEC_GRUMPHP_COMMAND: ['docker-compose', 'run', 'php']. |
| Windows Git Clients | Medium | Test with Git Bash or WSL; avoid path issues in git_hook_variables. |
| CI Without Git Hooks | High | Use grumphp run as a pipeline step. |
| Shared Hosting | Low | Git hooks may be disabled; rely on CI-only execution. |
| Legacy PHP (5.6) | Low | Avoid unless absolutely necessary; Laravel 5.5+ requires PHP 7.1+. |
Pre-Installation:
cp .git/hooks/* .git/hooks.backup).php, composer, and git are in PATH.Installation:
composer require --dev phpro/grumphp
grumphp git:init # Initialize hooks
Configuration:
grumphp.yml (e.g., only phpunit and psr12).CI Integration:
.github/workflows/laravel.yml:
- name: Run GrumPHP
run: composer grumphp
Monitoring:
| Aspect | Effort | Notes |
|---|---|---|
| Task Updates | Low | Tasks are Composer-managed; update via composer update. |
| Configuration Drift | Medium | Use grumphp.yml.dist for team-wide consistency. |
| Plugin Ecosystem | Low | Leverage Packagist for task plugins (e.g., grumphp/grumphp-task-phpunit). |
| Debugging | Medium | Use grumphp run --verbose for detailed logs. |
Maintenance Tasks:
grumphp.yml for deprecated tasks.grumphp logs if commits are blocked unexpectedly.| Issue Type | Resolution Path |
|---|---|
| Task Failures | Check task-specific docs (e.g., PHPStan config). |
| Hook Conflicts | Restore backups or use --no-scripts during composer install. |
| Performance Issues | Adjust max_workers or disable parallel mode. |
| CI Integration | Run grumphp run explicitly in pipelines. |
| Custom Task Errors | Debug with grumphp run --task=MyTask --verbose. |
Support Tools:
| Factor | Scalability | Optimization |
|---|---|---|
| Codebase Size | High | Parallel |
How can I help you explore Laravel packages today?