nocturnal / pre-commit-guard
Git pre-commit guard for Laravel apps (Pint, PHPStan, etc.)
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nocturnal/pre-commit-guard
Requires
- php: ^8.2|^8.3
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.13
- nunomaduro/larastan: ^3.7
- phpstan/phpstan: ^2.1.31
README
A Laravel package that helps enforce code quality checks before commits using Git hooks.
Installation
1. Require the Package
# For development (using path/VCS) composer config repositories.pre-commit-guard '{"type":"path","url":"../pre-commit-guard","options":{"symlink": true}}' composer require --dev nocturnal/pre-commit-guard nunomaduro/larastan
2. Remove Ad-Hoc Hook Installer (if any)
If you currently use custom hook installation scripts like:
post-install-cmd: ["@setup-dev-hooks"]"setup-dev-hooks": ["@php install-dev-hooks.php"]
You can remove them as this package provides a more robust solution.
3. Publish and Install Hooks
php artisan vendor:publish --tag=pre-commit-guard --force php artisan precommit:install --force
Usage
After installation, the Git pre-commit hook will automatically run Pint and PHPStan checks when you make a commit. The commit will be blocked if any of these checks fail.
Configuration
Presets
- Pint configuration and rules are included in the stubs and will be inherited by consuming projects.
- PHPStan configuration is also included in the stubs for consistent code quality checks.
Your existing Pint preset and rules will be preserved when installing this package.