Composer integration

If you want to make sure all of your teammates install the git hooks to their local repository you have two options.

1. Composer plugin

Additionally, to installing the Cap' you can require the captainhook/hook-installer package. This will install a Composer plugin, that executes the captainhook install command after you run any Composer command like install or update.

{
  "require-dev": {
    "captainhook/captainhook-phar": "^5.0"
    "captainhook/hook-installer": "^1.0"
  }
}

If you are using a PHAR release that you installed via PHIVE or you downloaded manually 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,
        "force-install": 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 these lines, Composer will execute the CaptainHook install command every time composer install or update is executed.

Watch out!

This method has the disadvantage that if you install your dependencies with --no-dev and the Cap'n is not installed this will crash your Composer command.

A word of warning matey: It is still possible to commit without invoking the hooks. So make sure you run appropriate backend-sanity checks on your code as well.