captainhook / captainhook
PHP git hook manager
Fund package maintenance!
sebastianfeldmann
Installs: 3 499 544
Dependents: 260
Suggesters: 2
Security: 0
Stars: 1 002
Watchers: 19
Forks: 87
Open Issues: 12
Requires
- php: >=8.0
- ext-json: *
- ext-spl: *
- ext-xml: *
- captainhook/secrets: ^0.9.4
- sebastianfeldmann/camino: ^0.9.2
- sebastianfeldmann/cli: ^3.3
- sebastianfeldmann/git: ^3.10
- symfony/console: ^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/filesystem: ^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/process: ^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- composer/composer: ~1 || ^2.0
- mikey179/vfsstream: ~1
Replaces
- dev-main / 6.0.x-dev
- 5.23.6
- 5.23.5
- 5.23.4
- 5.23.4-beta
- 5.23.4-alpha-2
- 5.23.4-alpha-1
- 5.23.3
- 5.23.2
- 5.23.1
- 5.23.0
- 5.22.2
- 5.22.1
- 5.22.0
- 5.21.2
- 5.21.1
- 5.21.0
- 5.20.2
- 5.20.1
- 5.20.0
- 5.19.2
- 5.19.1
- 5.19.0
- 5.18.3
- 5.18.2
- 5.18.1
- 5.18.0
- 5.17.3
- 5.17.2
- 5.17.1
- 5.17.0
- 5.16.4
- 5.16.3
- 5.16.2
- 5.16.1
- 5.16.0
- 5.15.6
- 5.15.5
- 5.15.4
- 5.15.3
- 5.15.2
- 5.15.1
- 5.15.0
- 5.14.4
- 5.14.3
- 5.14.2
- 5.14.1
- 5.14.0
- 5.13.0
- 5.12.0
- 5.11.2
- 5.11.1
- 5.11.0
- 5.10.11
- 5.10.10
- 5.10.9
- 5.10.8
- 5.10.7
- 5.10.6
- 5.10.5
- 5.10.4
- 5.10.3
- 5.10.2
- 5.10.1
- 5.10.0
- 5.9.0
- 5.8.1
- 5.8.0
- 5.7.0
- 5.6.2
- 5.6.1
- 5.6.0
- 5.5.1
- 5.5.0
- 5.4.5
- 5.4.4
- 5.4.3
- 5.4.2
- 5.4.1
- 5.4.0
- 5.3.3
- 5.3.2
- 5.3.1
- 5.3.0
- 5.2.1
- 5.2.0
- 5.1.3
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.0
- 5.0.0-RC5
- 5.0.0-RC4
- 5.0.0-RC3
- 5.0.0-RC2
- 5.0.0-RC1
- 4.5.8
- 4.5.7
- 4.5.6
- 4.5.5
- 4.5.4
- 4.5.3
- 4.5.2
- 4.5.1
- 4.5.0
- 4.4.3
- 4.4.2
- 4.4.1
- 4.4.0
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-beta1
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-10-30 14:23:04 UTC
README
CaptainHook
CaptainHook is an easy to use and very flexible git hook library for php developers. It enables you to configure your git hook actions in a simple json file.
You can use CaptainHook to validate or prepare your commit messages, ensure code quality or run unit tests before you commit or push changes to git. You can automatically clear local caches or install the latest composer dependencies after pulling the latest changes.
CaptainHook makes it easy to share hooks within your team and even can make sure that everybody in your team activates the hooks locally.
You can run cli commands, use some built in validators, or write your own PHP classes that get executed by CaptainHook. For more information have a look at the documentation.
Installation
The preferred method to install CaptainHook is to install the PHAR file. You can do so by using Phive or download the PHAR from the GitHub release page.
phive install captainhook
Or use Composer to install it.
composer require --dev captainhook/captainhook-phar
If you want to get the source code with all its dependencies you can use:
composer require --dev captainhook/captainhook
Setup
After installing CaptainHook you can use the captainhook executable to create a configuration.
vendor/bin/captainhook configure
After creating the captainhook.json configuration file you have to activate the hooks by installing them to your local .git directory. To do so just run the following CaptainHook command.
vendor/bin/captainhook install
Have a look at this short installation video.
One of the goals of CaptainHook is to make it easy for a team to use the same git hooks. If you want to make sure
everybody actually installs the hooks you can use the small Composer plugin hook-installer
.
It runs the captainhook install
command everytime you run a Composer command.
composer require --dev captainhook/hook-installer
Off course teammates can still commit without executing the hooks, that's why you should run appropriate checks on the backend as well. But at least this way nobody can forget to install them "by accident".
Configuration
Here's an example captainhook.json configuration file.
{ "commit-msg": { "enabled": true, "actions": [ { "action": "\\CaptainHook\\App\\Hook\\Message\\Action\\Beams", } ] }, "pre-commit": { "enabled": true, "actions": [ { "action": "phpunit" }, { "action": "phpcs --standard=psr2 src" } ] }, "pre-push": { "enabled": false, "actions": [] } }
Contributing
So you'd like to contribute to the CaptainHook
library? Excellent! Thank you very much.
I can absolutely use your help.
Have a look at the contribution guidelines.