PHPackages                             felipebool/crook - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. felipebool/crook

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

felipebool/crook
================

Crook is a simple tool to ease your life when dealing with git hooks

0.0.12(8y ago)5813.8k5MITPHPPHP ^7.1CI failing

Since Feb 8Pushed 5y ago3 watchersCompare

[ Source](https://github.com/felipebool/crook)[ Packagist](https://packagist.org/packages/felipebool/crook)[ RSS](/packages/felipebool-crook/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (0)

[![Build Status](https://camo.githubusercontent.com/d50ea25cc3d83f60abb6ff7af13faf0e98649271f9ae557526e88dcf3427cd62/68747470733a2f2f7472617669732d63692e6f72672f66656c697065626f6f6c2f63726f6f6b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/felipebool/crook)[![Maintainability](https://camo.githubusercontent.com/430c52de62c956edd3475971ca97b0cf36ade02b2ae2189ac267a31195070205/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f64646137626263303435613935353533306461342f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/felipebool/crook/maintainability)[![Codacy Badge](https://camo.githubusercontent.com/66da17ede20cb73041cd524f346ed2c0a76a0cb8b08cc5e16f17c7e6f965f8f7/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3238343938353966643161643464323939626637343033613835313731333139)](https://www.codacy.com/app/felipebool/crook?utm_source=github.com&utm_medium=referral&utm_content=felipebool/crook&utm_campaign=Badge_Grade)[![Codacy Badge](https://camo.githubusercontent.com/d40f8f222d0ad8057a1ef5f7b2889774962c8465ced6f76069e679c1f70a42ad/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f3238343938353966643161643464323939626637343033613835313731333139)](https://www.codacy.com/app/felipebool/crook?utm_source=github.com&utm_medium=referral&utm_content=felipebool/crook&utm_campaign=Badge_Coverage)

Crook
=====

[](#crook)

First of all, Crook is a work in progress.

If you are not familiar with git hooks, you may want to read [Git Hooks documentation](https://git-scm.com/docs/githooks) first.

Crook is the simplest way to define and manage your Git Hooks. Its aim is to allow scripts from your composer.json run when git hook actions are triggered.

Usage
-----

[](#usage)

The aim of this project is to be as simple as possible, thus, you won't have to write any PHP code, you just need to install any packages from packagist and then make them run for partucular git hooks. The process is explained in the following sections.

### Installation

[](#installation)

Just run

`$ composer require felipebool/crook --dev`

### Init Crook

[](#init-crook)

`$ vendor/bin/crook init` will create crook.json configuration file and theHook in the root of your project.

### Add a new hook

[](#add-a-new-hook)

`$ vendor/bin/crook add hook-name action-name` will create a symbolic link from .git/hooks/hook-name to theHook, enabling that hook.

### Remove a hook

[](#remove-a-hook)

`$ vendor/bin/crook remove hook-name` will remove the symbolic link .git/hooks/hook-name, disabling that hook.

### Add a action to composer.json

[](#add-a-action-to-composerjson)

When you add a new action using `add` you need to add what is expected to run when that action is triggered inside you composer.json. To do that, you must create a new entry inside the section `scripts` and then define what must run there.

Crook configuration file
------------------------

[](#crook-configuration-file)

Crook uses a json configuration file just like composer, it is called crook.json. The configuration is made, basically, by writting as a key the git hook name and as value the respective script entry in composer.json. See the following example

```
{
  "pre-commit": "code-check",
  "composer": "/home/felipe/bin/composer"
}
```

Although you are able to edit crook.json by yourself, you should do it using `$ vendor/bin/crook` in order to create the symbolic links. Only the composer path **must** be set manually. The mechanism is explained in the next section.

The mechanism
-------------

[](#the-mechanism)

Every time you run a `vendor/bin/crook add hook-name action-name`Crook creates a symbolic link from .git/hooks/hook-name to /your/project/hook/theHook, simple as that.

Now, when git trigger the action hook-name, it will follow the link to /your/project/hook/theHook and Crook will then look for a script named action-name inside your project's composer.json and will execute the commands defined there.

### Adding code validation using phpcs before any commit

[](#adding-code-validation-using-phpcs-before-any-commit)

In order to check your code against PSR2, you must do this

#### Add the script action inside composer.json

[](#add-the-script-action-inside-composerjson)

```
"scripts": {
  "code-check": "phpcs --standard=PSR2 src/",
}

```

#### Initialize crook

[](#initialize-crook)

`$ vendor/bin/crook init`

#### Bind code-check to pre-commit hook

[](#bind-code-check-to-pre-commit-hook)

`$ vendor/bin/crook add pre-commit code-check`

Next time you run `$ git commit -m 'some message'` crook will run the code defined inside code-check and will prevent code from being commited if the check fail.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% 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 ~0 days

Total

12

Last Release

3015d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d268e69e8a891abcd1ee976e3c2a56bff892b7ecf2394ab22ce286004eae7c38?d=identicon)[felipebool](/maintainers/felipebool)

---

Top Contributors

[![felipebool](https://avatars.githubusercontent.com/u/856795?v=4)](https://github.com/felipebool "felipebool (52 commits)")[![ginfarma](https://avatars.githubusercontent.com/u/127508196?v=4)](https://github.com/ginfarma "ginfarma (4 commits)")

---

Tags

composergitgithookhookspackagistphpgithooksgithookcrook

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[captainhook/captainhook

PHP git hook manager

1.1k6.8M370](/packages/captainhook-captainhook)[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)[marcocesarato/php-conventional-changelog

Generate changelogs and release notes from a project's commit messages and metadata and automate versioning with semver.org and conventionalcommits.org

2511.3M109](/packages/marcocesarato-php-conventional-changelog)[wcm/git-php-hooks

Write git hooks with PHP, organize them on a per-project base and automatically add them

6441.1k3](/packages/wcm-git-php-hooks)[bernardosilva/git-hooks-php

Composer git-hook package with hooks for your php projects.

2516.7k1](/packages/bernardosilva-git-hooks-php)[nilportugues/php_backslasher

Adds all PHP internal functions to its namespace by adding backslash to them. Improves the application's performance when OPCache is on.

889.3k18](/packages/nilportugues-php-backslasher)

PHPackages © 2026

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