Giter Club home page Giter Club logo

php-git-hooks's Introduction

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.

Original scripts

Installation

Step 1: Composer

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

{
    "require-dev": {
        "bruli/php-git-hooks": "^2.0"
    }
}

Or you can write in your console:

$ composer require bruli/php-git-hooks --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": [
      ...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.

Bin directory configuration.

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

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

Note: Not necessary for Symfony projects.

Manual config file for git hooks.

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

pre-commit:
  enabled: true
  execute:
    php-cs-fixer:
        enabled:  true
        levels:
            psr0:       true
            psr1:       true
            psr2:       true
            symfony:    true
    phpunit:       true
    phplint:       true
    phpcs:         true
    phpmd:         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.

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

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

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.

####Valid pre-commit. ####Fail pre-commit.

Credits

License

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

php-git-hooks's People

Contributors

bruli avatar patxi1980 avatar neoshadybeat avatar theunic avatar glensc avatar lgarciaes avatar

Watchers

James Cloos avatar Andrew Kovalyov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.