- How do I install GrumPHP in a Laravel project?
- Run `composer require --dev phpro/grumphp` in your Laravel project root. This installs GrumPHP as a Composer plugin and registers Git hooks automatically. Ensure PHP, Composer, and Git are in your system PATH for it to work.
- Which Laravel versions does GrumPHP support?
- GrumPHP works with Laravel 5.5+ (PHP 7.1+). It’s compatible with all modern Laravel versions, including 8.x and 9.x. For older Laravel 5.x projects, ensure PHP 7.1+ is used to avoid compatibility issues.
- Can GrumPHP run PHPUnit and Pest tests before commits?
- Yes. Configure PHPUnit or Pest tasks in `grumphp.yml` under `tasks`. Example: `phpunit: ~` or `pest: ~`. GrumPHP will execute these tasks on every commit and block the commit if tests fail.
- How do I skip GrumPHP checks for a specific commit?
- Use `git commit --no-verify` to bypass Git hooks. Alternatively, run `grumphp run --no-assumption` manually to execute checks without committing. This is useful for emergency fixes or CI-only environments.
- Does GrumPHP work in CI/CD pipelines without Git hooks?
- Yes. Run `grumphp run` as a CI step to enforce checks without relying on Git hooks. This is ideal for environments like GitHub Actions, GitLab CI, or Laravel Forge where hooks may be disabled.
- How do I configure GrumPHP for Laravel-specific tasks like laravel-pint?
- Add `laravel-pint` to `grumphp.yml` under `tasks` with the correct path. Example: `laravel-pint: ~`. Ensure the task is installed via Composer (`composer require --dev laravel/pint`).
- What’s the performance impact of GrumPHP on large Laravel codebases?
- GrumPHP is optimized for performance with parallel task execution. Enable it in `grumphp.yml` with `parallel.enabled: true` and adjust `max_workers` (default: 32). For monorepos, configure `hooks_dir` and `git_hook_variables` carefully.
- How do I handle Git hook conflicts with existing hooks?
- GrumPHP backs up existing hooks during installation. If conflicts occur, manually resolve them by editing `.git/hooks/` or use `--no-scripts` during `composer install` to skip hook registration.
- Can GrumPHP enforce stricter rules in production environments?
- Yes. Use environment-specific configurations in `grumphp.yml` with `parameters` or custom tasks. Example: Add `phpstan: ~` only for `APP_ENV=production` via conditional logic in your task setup.
- What are the alternatives to GrumPHP for Laravel?
- Alternatives include Laravel’s built-in `php artisan test` (manual), GitHub Actions for CI checks, or custom scripts with `pre-commit` hooks. However, GrumPHP offers deeper integration with PHP tools (PHPStan, Pest) and Laravel-specific tasks.