PHPackages                             captainhook/captainhook - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. captainhook/captainhook

ActiveLibrary[Testing &amp; Quality](/categories/testing)

captainhook/captainhook
=======================

PHP git hook manager

5.29.2(1mo ago)1.1k6.8M—6%89[8 issues](https://github.com/captainhook-git/captainhook/issues)[1 PRs](https://github.com/captainhook-git/captainhook/pulls)20MITPHPPHP &gt;=8.0CI passing

Since Sep 7Pushed 1mo ago15 watchersCompare

[ Source](https://github.com/captainhook-git/captainhook)[ Packagist](https://packagist.org/packages/captainhook/captainhook)[ Docs](https://php.captainhook.info/)[ GitHub Sponsors](https://github.com/sponsors/sebastianfeldmann)[ RSS](/packages/captainhook-captainhook/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (178)Used By (20)

[![Latest Stable Version](https://camo.githubusercontent.com/588384bb095e9bb641a0a85874f97c92636f02308fac6580e7480fd1be5f0c55/68747470733a2f2f706f7365722e707567782e6f72672f6361707461696e686f6f6b2f6361707461696e686f6f6b2f762f737461626c652e7376673f763d31)](https://packagist.org/packages/captainhook/captainhook)[![PHP Version](https://camo.githubusercontent.com/ac1e1d3207c4fc9f26af9b4115e52358701df0bb8c6bac7b936dcfc8e71c27ff/68747470733a2f2f706f7365722e707567782e6f72672f6361707461696e686f6f6b2f6361707461696e686f6f6b2f726571756972652f706870)](https://packagist.org/packages/captainhook/captainhook)[![Downloads](https://camo.githubusercontent.com/715352b27c955ac3153e9e350bb95401f3705dcd3b574517bf26b03a97c0c87d/68747470733a2f2f706f7365722e707567782e6f72672f6361707461696e686f6f6b2f6361707461696e686f6f6b2f646f776e6c6f616473)](https://packagist.org/packages/captainhook/captainhook/stats)[![Downloads](https://camo.githubusercontent.com/b489b15372df5a41be655ee43b83a28a4bf7fb20f45e81983f25b3294ae55241/68747470733a2f2f706f7365722e707567782e6f72672f6361707461696e686f6f6b2f6361707461696e686f6f6b2f642f6d6f6e74686c79)](https://packagist.org/packages/captainhook/captainhook/stats)[![Downloads](https://camo.githubusercontent.com/edde0f2fad2927120d8b0d7fd9b8aeaaed3d2ae88c8b04297acc74a54cd5fe36/68747470733a2f2f706f7365722e707567782e6f72672f6361707461696e686f6f6b2f6361707461696e686f6f6b2f642f6461696c79)](https://packagist.org/packages/captainhook/captainhook/stats)[![License](https://camo.githubusercontent.com/d1cd643f8c11592fa77cf4c17e521c059adb89ffd913bd62409ba22291d5f345/68747470733a2f2f706f7365722e707567782e6f72672f6361707461696e686f6f6b2f6361707461696e686f6f6b2f6c6963656e73652e7376673f763d31)](https://github.com/captainhook-git/captainhook/blob/main/LICENSE)[![Build Status](https://github.com/captainhook-git/captainhook/workflows/Continuous%20Integration/badge.svg)](https://github.com/captainhook-git/captainhook/actions)[![Code Quality](https://camo.githubusercontent.com/d337f008265979643be09c5cd643265de645528b515f45b6e90d8a819d3e242b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6361707461696e686f6f6b2d6769742f6361707461696e686f6f6b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e26763d31)](https://scrutinizer-ci.com/g/captainhook-git/captainhook/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/ad949aa656d2e06da8a414781c09c4c483d5234f29ebc445f1588ac1cadf9f3f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6361707461696e686f6f6b2d6769742f6361707461696e686f6f6b2f6261646765732f636f7665726167652e706e673f623d6d61696e26763d31)](https://scrutinizer-ci.com/g/captainhook-git/captainhook/?branch=master)[![X](https://camo.githubusercontent.com/bd7a434e9ace4deb8212da76cce07892bf887a3b27568dcd464b4d15ddb1c6a8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d2534306361707461696e686f6f6b6769742d626c61636b2e737667)](https://twitter.com/intent/user?screen_name=captainhookgit)[![Mastodon](https://camo.githubusercontent.com/667ccfeb74486fa0d9f369d6672b8d1d56b43554c0e3ce8b932f604f838ea71e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6173746f646f6e2d2534306361707461696e686f6f6b2d707572706c652e737667)](https://phpc.social/@captainhook)

CaptainHook
===========

[](#captainhook)

[![CaptainHook logo](https://camo.githubusercontent.com/493bf1a29ce67c6517fb948a254fbd372d87e70da7daa4f63b3dc87834e17a08/68747470733a2f2f6361707461696e686f6f6b2d6769742e6769746875622e696f2f6361707461696e686f6f6b2f6766782f63682e706e67)](https://camo.githubusercontent.com/493bf1a29ce67c6517fb948a254fbd372d87e70da7daa4f63b3dc87834e17a08/68747470733a2f2f6361707461696e686f6f6b2d6769742e6769746875622e696f2f6361707461696e686f6f6b2f6766782f63682e706e67)

*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](https://php.captainhook.info/ "CaptainHook Documentation").

Installation
------------

[](#installation)

The preferred method to install *CaptainHook* is to install the PHAR file. You can do so by using [Phive](https://phar.io/), use the PHAR Composer package, or download the PHAR from the GitHub [release page](https://github.com/captainhook-git/captainhook/releases/latest).

```
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
-----

[](#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.

[![Install demo](https://camo.githubusercontent.com/16c34b9e903777a7a8606fba9bffb8d597f354466b728b9dbc4e69fe9940ed59/687474703a2f2f696d672e796f75747562652e636f6d2f76692f71517944632d57786b37592f68713732302e6a7067)](http://www.youtube.com/watch?v=qQyDc-Wxk7Y)

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
-------------

[](#configuration)

Here's an example *captainhook.json* configuration file.

```
{
  "commit-msg": {
    "actions": [
      {
        "action": "CaptainHook.Message.MustFollowBeamsRules"
      }
    ]
  },
  "pre-commit": {
    "actions": [
      {
        "action": "phpunit"
      },
      {
        "action": "phpcs --standard=psr12 src"
      }
    ]
  }
}
```

Documentation
-------------

[](#documentation)

The full documentation can be found at [php.captainhook.info](https://php.captainhook.info/ "CaptainHook dcoumentation").

Contributing
------------

[](#contributing)

So you'd like to contribute to the `CaptainHook` project? Excellent! Thank you very much. I can absolutely use your help.

Have a look at the [contribution guidelines](CONTRIBUTING.md).

###  Health Score

77

—

ExcellentBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity69

Solid adoption and visibility

Community52

Growing community involvement

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 93.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~19 days

Recently: every ~6 days

Total

177

Last Release

54d ago

Major Versions

1.2.1 → 2.0.0-beta12017-01-23

2.2.0 → 3.0.02018-11-26

3.1.0 → 4.0.02019-01-10

4.5.8 → 5.0.0-RC12019-12-27

PHP version history (7 changes)2.0.0PHP &gt;=7.0.0

4.0.0PHP &gt;=7.1.0

4.3.1PHP ^7.1

5.0.0-RC1PHP ^7.2

5.4.4PHP &gt;=7.2

5.15.0PHP &gt;=7.4

5.19.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9250358?v=4)[Sebastian Feldmann](/maintainers/sebastianfeldmann)[@sebastianfeldmann](https://github.com/sebastianfeldmann)

---

Top Contributors

[![sebastianfeldmann](https://avatars.githubusercontent.com/u/9250358?v=4)](https://github.com/sebastianfeldmann "sebastianfeldmann (1206 commits)")[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (17 commits)")[![fxedel](https://avatars.githubusercontent.com/u/7782229?v=4)](https://github.com/fxedel "fxedel (11 commits)")[![alexandrmazur96](https://avatars.githubusercontent.com/u/20535375?v=4)](https://github.com/alexandrmazur96 "alexandrmazur96 (9 commits)")[![be-heiglandreas](https://avatars.githubusercontent.com/u/60882198?v=4)](https://github.com/be-heiglandreas "be-heiglandreas (7 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (5 commits)")[![heiglandreas](https://avatars.githubusercontent.com/u/91998?v=4)](https://github.com/heiglandreas "heiglandreas (4 commits)")[![icanhazstring](https://avatars.githubusercontent.com/u/883543?v=4)](https://github.com/icanhazstring "icanhazstring (4 commits)")[![chriskapp](https://avatars.githubusercontent.com/u/2505846?v=4)](https://github.com/chriskapp "chriskapp (3 commits)")[![iherak](https://avatars.githubusercontent.com/u/5854428?v=4)](https://github.com/iherak "iherak (3 commits)")[![aboks](https://avatars.githubusercontent.com/u/815524?v=4)](https://github.com/aboks "aboks (2 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![PurpleBooth](https://avatars.githubusercontent.com/u/133327?v=4)](https://github.com/PurpleBooth "PurpleBooth (2 commits)")[![pyrokar](https://avatars.githubusercontent.com/u/949836?v=4)](https://github.com/pyrokar "pyrokar (2 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (2 commits)")[![Wirone](https://avatars.githubusercontent.com/u/600668?v=4)](https://github.com/Wirone "Wirone (2 commits)")[![davidjeddy](https://avatars.githubusercontent.com/u/6232455?v=4)](https://github.com/davidjeddy "davidjeddy (1 commits)")[![norgeindian](https://avatars.githubusercontent.com/u/11156287?v=4)](https://github.com/norgeindian "norgeindian (1 commits)")[![bcremer](https://avatars.githubusercontent.com/u/55820?v=4)](https://github.com/bcremer "bcremer (1 commits)")[![shochdoerfer](https://avatars.githubusercontent.com/u/596449?v=4)](https://github.com/shochdoerfer "shochdoerfer (1 commits)")

---

Tags

automationcode-qualitygitgit-hookshacktoberfestphpgithookspre-commitpre-pushcommit-msgprepare-commit-msgpost-merge

### Embed Badge

![Health badge](/badges/captainhook-captainhook/health.svg)

```
[![Health](https://phpackages.com/badges/captainhook-captainhook/health.svg)](https://phpackages.com/packages/captainhook-captainhook)
```

###  Alternatives

[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[ramsey/conventional-commits

A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook action!

1931.2M122](/packages/ramsey-conventional-commits)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
