2017 © Pedro Peláez
 

library php-git-hooks

Git hooks for PHP projects.

image

jeleb-smile/php-git-hooks

Git hooks for PHP projects.

  • Wednesday, October 11, 2017
  • by jeleb-smile
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1,034 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 96 Forks
  • 0 Open issues
  • 52 Versions
  • 0 % Grown

The README.md

php-git-hooks

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight, (*1)

Git hooks for PHP projects., (*2)

Library based in git hook scripts for PHP projects., (*3)

Original scripts, (*4)

Installation

Step 1: Composer

You must add the following line to the composer.json file to use with Symfony 3.0:, (*5)

{
    "require-dev": {
        "bruli/php-git-hooks": "~3.0"
    }
}

You can use "~2.0" for Symfony version 2.X., (*6)

Or you can write in your console:, (*7)

$ composer require bruli/php-git-hooks --dev

If you don't have composer, you need download the binary file and run it:, (*8)

wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar

php composer.phar install

Step 2: Configuration

Composer configuration.

After download all repositories, composer ask you about configuration., (*9)

, (*10)

Composer configuration in Symfony2 projects.

In Symfony2 projects you need add this lines in your composer.json:, (*11)

"scripts": {
    "post-install-cmd": [
      ...other lines...
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ],
    "post-update-cmd": [
      ...other lines...
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ]

Important: To use 2.X version you need symfony 2.7 version., (*12)

Bin directory configuration.

If your project haven't a "bin" directory, you can add this in your compose.json file., (*13)

 "config": {
        "bin-dir": "bin"
    }

Note: Not necessary for Symfony projects., (*14)

Manual config file for git hooks.

You can configure php-git-hooks, creating a php-git-hooks.yml file with..., (*15)

pre-commit:
  enabled: true
  execute:
    php-cs-fixer:
        enabled:  true
        levels:
            psr0:       true
            psr1:       true
            psr2:       true
            symfony:    true
    phpunit:
        enabled:     true
        random-mode: true
    phplint:         true
    phpcs:
        enabled:     true
        standard:    PSR2
    phpmd:           true
    composer:        true
commit-msg:
    enabled: true
    regular-expression: '#[0-9]{2,7}'

... or you can copy php-git-hooks.yml.sample from vendor/bruli/php-git-hooks., (*16)

Update from v1.3.*

Php-cs-fixer configuration in php-git-hooks.yml file, is not compatible with 2.0 version. You should remove php-cs-fixer entry and execute "composer install"., (*17)

Most easy way to update is delete php-git-hooks.yml and execute "composer install". You will see all the configuration questions again., (*18)

Config file for phpunit.

If you want use phpunit tool, you must create a phpunit.xml.dist in your project root directory. Alternatively you can copy from vendor/bruli/php-git-hooks/phpunit.xml.dist in your project root directory., (*19)

Config file for phpmd.

The same case that phpunit. You must create a PmdRules.xml in your project root directory or copy from php-git-hook directory., (*20)

Step 3: Enabling hooks.

The most easy way to enable hook is copy hook file into your .git/hooks directory., (*21)

For pre-commit hook:

You can enable this hooks with composer or manually executing, (*22)

 $cp vendor/bruli/php-git-hooks/hooks/pre-commit .git/hooks

For commit-msg hook:

 $cp vendor/bruli/php-git-hooks/hooks/commit-msg .git/hooks

execute.

Valid pre-commit.

, (*23)

Fail pre-commit.

, (*24)

Credits

License

php-git-hooks is released under the MIT License. See the bundled LICENSE file for details., (*25)

The Versions