grumphp
Automate PHP code quality checks and standardization
TLDR
Register the Git hooks
Trigger the pre-commit hook manually
Check every versioned file
SYNOPSIS
grumphp <command> [options] [arguments]
Examples: grumphp run, grumphp git:init
PARAMETERS
run
Execute all configured tasks on staged Git files
git:init
Install or upgrade Git hooks in the repository
git:hooks
List installed Git hooks
debug
Debug configuration and tasks
self-update
Update GrumPHP to latest version
--dry-run
Simulate tasks without executing them
--skip-tasks
Comma-separated list of tasks to skip (e.g., 'phpcs,phpstan')
--test-framework
Specify test framework: 'phpunit' or 'pest'
--testsuite
PHPUnit testsuite to run (e.g., 'default')
--git-format
Output format: 'github', 'gitlab', 'bitbucket', 'default'
-v|--verbose
Increase verbosity (-v, -vv, -vvv)
--no-interaction
Run non-interactively
--ansi|--no-ansi
Force (no) ANSI output
-h|--help
Show help for command
--version
Show GrumPHP version
DESCRIPTION
GrumPHP is a flexible Composer plugin for PHP projects that integrates with Git to enforce code quality during commits. It installs Git hooks (pre-commit, pre-push, etc.) which automatically execute a series of configurable tasks on staged files before allowing a commit.
Tasks include PHP linting, coding standards enforcement (PHP-CS-Fixer, PHPCS), static analysis (PHPStan, Psalm), security checks, YAML validation, Composer scripts, and more. Configuration is done via grumphp.yml in the project root, specifying tasks, triggers, and options.
If any task fails, the commit or push is rejected, ensuring only high-quality code enters the repository. Supports parallel execution, dry runs, and integration with CI/CD. Ideal for teams maintaining consistent standards without manual checks.
GrumPHP does not fix issues automatically but blocks bad code; pair with auto-fixers for best results. Widely used in modern PHP development for scalable quality gates.
CAVEATS
Not a native Linux binary; install via Composer (composer require --dev phpro/grumphp). Requires PHP >=8.1. Project-specific; run ./vendor/bin/grumphp or add to PATH. Git hooks may conflict with other hook managers.
CONFIGURATION
Edit grumphp.yml for tasks:
tasks:
php:
enabled: true
INSTALLATION
composer require --dev phpro/grumphp
./vendor/bin/grumphp git:init
Commit grumphp.yml.dist for teams.
HISTORY
Created in 2013 by phpro to automate PHP QA in Git workflows. Evolved from simple hooks to full-featured tool with 100+ tasks. Major v1 release 2015; current v1.17+ (2024) supports PHP 8.3, modern analyzers like Rector 1.x.


