Spryker Git hooks

dev-master 2023-11-02 18:51 UTC

This package is auto-updated.

Last update: 2024-05-27 19:37:21 UTC


CI Minimum PHP Version PHPStan License

GitHook for Spryker. This tool will add Git hooks to your local hooks directory.

Currently, we have only one hook named pre-commit. This will execute on every commit the applied commands.


composer require --dev spryker/git-hook


Add the Composer scripts to your composer.json

For core

    "scripts": {
        "post-install-cmd": [
    "post-update-cmd": [

For projects

  "scripts": {
    "post-install-cmd": [
    "post-update-cmd": [

This will copy the git hooks to your .git/hooks/ directory.


Place a .githook file into the root of your project. Inside of this file you can configure the commands.

You can also use your private configuration by creating a .githook_local file and ignore it in your projects .gitignore` file.

Enable commands

To enable commands you need to specify them. An example configuration could look like this:

    - GitHook\Command\FileCommand\PreCommit\ArchitectureCheckCommand
    - GitHook\Command\FileCommand\PreCommit\CodeStyleCheckCommand
    - GitHook\Command\FileCommand\PreCommit\CodeStyleFixCommand
    - GitHook\Command\FileCommand\PreCommit\PhpMdCheckCommand
    - GitHook\Command\FileCommand\PreCommit\PhpStanCheckCommand

    - GitHook\Command\RepositoryCommand\PreCommit\ValidateBranchNameCommand
    - GitHook\Command\RepositoryCommand\PreCommit\GitAddCommand

See the full list of available commands in src/GitHook/Command/FileCommand/ and src/GitHook/Command/RepositoryCommand/.

Note: GitHook\Command\RepositoryCommand\PreCommit\GitAddCommand will automatically add all new files into commit, when other commands changed the files ( CodeStyleFixCommand does it for example), so use it only when you really need it!

PhpStanCheckCommand configuration

        level: 8
        config: .phpstan.neon


We have two different type of commands. FileCommands will be executed for each file of a given commit. RepositoryCommands will be executed on the whole repository.