PHPackages                             unh3ck3d/php-cs-fixer-git-hook - 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. unh3ck3d/php-cs-fixer-git-hook

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

unh3ck3d/php-cs-fixer-git-hook
==============================

Git hook running PHP CS Fixer on staged files using CaptainHook

v1.0.0(2y ago)010.3k↓31.6%11MITPHPPHP ^8.0

Since Nov 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Unh3ck3d/php-cs-fixer-git-hook)[ Packagist](https://packagist.org/packages/unh3ck3d/php-cs-fixer-git-hook)[ Docs](https://github.com/Unh3ck3d/php-cs-fixer-git-hook)[ RSS](/packages/unh3ck3d-php-cs-fixer-git-hook/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (1)

[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/Unh3ck3d/php-cs-fixer-git-hook/blob/main/LICENSE)[![Code coverage](https://camo.githubusercontent.com/ec335b6d30f1b139825e908228a40fb67d2bec109287aec9cb9a518f86397e74/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f556e6833636b33642f7068702d63732d66697865722d6769742d686f6f6b3f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/Unh3ck3d/php-cs-fixer-git-hook)

### php-cs-fixer-git-hook

[](#php-cs-fixer-git-hook)

 Git hook running PHP CS Fixer on staged files using CaptainHook
[Report Bug](https://github.com/Unh3ck3d/php-cs-fixer-git-hook/issues)· [Request Feature](https://github.com/Unh3ck3d/php-cs-fixer-git-hook/issues)

About The Project
-----------------

[](#about-the-project)

Git hook that with each `git commit` command runs Php Cs Fixer on staged files to automatically fix them and re-stage before committing.

([back to top](#readme-top))

Requirements
------------

[](#requirements)

- [PHP](https://www.php.net/) &gt;= 8.0
- [CaptainHook](http://captainhook.info/) &gt;= 5.0
- [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)

([back to top](#readme-top))

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

[](#installation)

1. Install package as a dev dependency using composer ```
    composer require --dev unh3ck3d/php-cs-fixer-git-hook

    ```
2. Add the following code to your `captainhook.json` configuration file ```
    {
      "pre-commit": {
        "enabled": true,
        "actions": [
          {
            "action": "\\Unh3ck3d\\PhpCsFixerGitHook\\LintStagedFiles"
          }
        ]
      }
    }

    ```
3. Install newly added hook by following [CaptainHook docs](http://captainhook.info/install.html)

That's it. From now on after running `git commit` files that were staged will be automatically fixed by Php Cs Fixer.

([back to top](#readme-top))

Configuration
-------------

[](#configuration)

You can customize the behaviour how git hook is run by changing following options

OptionDescriptionphpCsFixerPathPath to Php Cs Fixer executable. Defaults to `./vendor/bin/php-cs-fixer`.pathMode`path-mode` cli option of Php Cs Fixer. Defaults to `intersection`.config`config` cli option of Php Cs Fixer. Defaults to `.php-cs-fixer.dist.php`.additionalArgsString of additional arguments that will be passed to Php Cs Fixer process.e.g.

```
{
  "pre-commit": {
    "enabled": true,
    "actions": [
      {
        "action": "\\Unh3ck3d\\PhpCsFixerGitHook\\LintStagedFiles",
        "options": {
            "phpCsFixerPath": "php-cs-fixer.phar",
            "pathMode": "overwrite",
            "config": ".php-cs-fixer.php",
            "additionalArgs": "-v --dry-run --diff"
        }
      }
    ]
  }
}

```

([back to top](#readme-top))

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

([back to top](#readme-top))

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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

Unknown

Total

1

Last Release

924d ago

### Community

Maintainers

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

---

Top Contributors

[![Unh3ck3d](https://avatars.githubusercontent.com/u/35114795?v=4)](https://github.com/Unh3ck3d "Unh3ck3d (4 commits)")[![DominikZaluskiCleeng](https://avatars.githubusercontent.com/u/108726803?v=4)](https://github.com/DominikZaluskiCleeng "DominikZaluskiCleeng (3 commits)")

---

Tags

captainhookcaptainhook-extensiongithooklintphpphp-cs-fixerphplintgitHOOKphp-cs-fixercaptainhookcaptainhook-extension

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/unh3ck3d-php-cs-fixer-git-hook/health.svg)

```
[![Health](https://phpackages.com/badges/unh3ck3d-php-cs-fixer-git-hook/health.svg)](https://phpackages.com/packages/unh3ck3d-php-cs-fixer-git-hook)
```

###  Alternatives

[captainhook/captainhook

PHP git hook manager

1.1k6.8M370](/packages/captainhook-captainhook)[moxio/captainhook-eslint

Captain Hook Plugin to validate files using ESLint

1147.9k](/packages/moxio-captainhook-eslint)[hot/phpunit-runner

The lib allows to watch phpunit tests

3066.9k4](/packages/hot-phpunit-runner)

PHPackages © 2026

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