定制 sdieunidou/php-git-hooks 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sdieunidou/php-git-hooks

最新稳定版本:v2.0.1

Composer 安装命令:

composer require sdieunidou/php-git-hooks

包简介

Git hooks for PHP projects.

README 文档

README

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.*@dev"
    }
}

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-config.png

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
        level:    psr0
    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. pre-commit.png ####Fail pre-commit. pre-commit-failed.png

Credits

License

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

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 111
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-03