Composer integration
If you want to make sure everybody in your team installs the git hooks to their local repository you have two options.
1. Composer plugin
Additionally to requiring captainhook/captainhook in your composer.json file you can require captainhook/plugin-composer. This will install CaptainHook and a composer plugin, that makes sure the hooks get activated for everyone's local repository.
{
"require-dev": {
"captainhook/plugin-composer": "^5.0"
}
}
If you are using the PHAR release you have to configure the path to your PHAR file using the extra configuration in your composer.json file. You can also configure a custom CaptainHook configuration path or file name.
{
"extra": {
"captainhook": {
"exec": "tools/captainhook.phar",
"config": "hooks.json",
"disable-plugin": false
}
}
}
2. Post install command
If you don't want to use the Composer plugin you can use the post-autoload-dump command just add the following lines to your projects composer.json file.
{
"scripts": {
"post-autoload-dump": "vendor/bin/captainhook install -f -s"
}
}
Including this lines, Composer will execute the CaptainHook install command every time composer install or update is executed.
A word of warning
It is still possible to commit without invoking the hooks. So make sure you run appropriate backend-sanity checks on your code!