neoshadybeat / php-git-hooks

Git hooks for PHP projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-git-hooks

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight

Git hooks for PHP projects.

Library based in git hook scripts for PHP projects, using in Atrápalo.

Original scripts

Installation

Step 1: Composer

You must add the following line to the composer.json file:

{
    "require-dev": {
        "bruli/php-git-hooks": "1.*@dev"
    }
}

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

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.

Composer configuration in Symfony2 projects.

In Symfony2 projects you need add this lines in your composer.json:

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

Manual config file for git hooks.

You can configure php-git-hooks, creating a php-git-hook.yml file with...

pre-commit:
  execute:
    php-cs-fixer:  true
    phpunit:       true
    phplint:       true
    phpcs:         true
    phpmd:         true

... or you can copy php-git-hooks.yml.sample from vendor/bruli/php-git-hooks.

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.

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.

Step 3: Enabling hooks.

The most easy way to enable hook is copy hook file into your .git/hooks directory.

#For pre-commit hook:

You can enable this hooks with composer or manually executing

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

Credits

License

php-git-hooks is released under the MIT License. See the bundled LICENSE file for details.

About

Git hooks for PHP projects

License:MIT License


Languages

Language:PHP 100.0%