• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

bruli/php-git-hooks: Git hooks for PHP projects

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

bruli/php-git-hooks

开源软件地址:

https://github.com/bruli/php-git-hooks

开源编程语言:

PHP 99.8%

开源软件介绍:

php-git-hooks

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

Git hooks for PHP projects.

Library based in git hook scripts for PHP projects.

Installation

Step 1: Composer

You must add the following line to the composer.json file to use with Symfony 3.0:

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

You can use "~2.0" for Symfony version 2.X.

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

Using Composer

First, you will need to add the following lines to your composer.json

"scripts": {
    "post-install-cmd": [
      "PhpGitHooks\\Infrastructure\\Composer\\ConfiguratorScript::buildConfig"
    ],
    "post-update-cmd": [
      "PhpGitHooks\\Infrastructure\\Composer\\ConfiguratorScript::buildConfig"
    ]
}

WARNING: "PhpGitHooks\Application\Composer\ConfiguratorScript::buildConfig" is deprecated. You need change by current entry.

Then, launch $ composer install and composer should ask you about configuration

Bin directory configuration.

If your project doesn't have a "bin/" directory, you can add this in your composer.json file.

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

Note: This is 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
        options: "--fixers=short_array_syntax --diff"
    phpunit:
        enabled:     true
        random-mode: true
        options:     '<some options>'
        strict-coverage:
             enabled:       true
             minimum:       90
        guard-coverage:
             enabled: true
             message: 'WARNING!!, your code coverage is lower.'
    phplint:         true
    phpcs:
        enabled:     true
        standard:    PSR2
    phpmd:
        enabled:     true
        options:     '<some options>'
    composer:        true
  message:
    right-message: 'HEY, GOOD JOB!!'
    error-message: 'FIX YOUR CODE!!'
commit-msg:
    enabled: true
    regular-expression: '#[0-9]{2,7}'
pre-push:
    enabled: true
    execute:
      phpunit:
        enabled:     true
        random-mode: true
        options:     '<some options>'
    strict-coverage:
        enabled:       true
        minimum:       90
    guard-coverage:
        enabled: true
        message: 'WARNING!!, your code coverage is lower.'
    message:
      right-message: 'PUSH IT!!'
      error-message: 'YOU CAN NOT PUSH CODE!!'

... 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/src/PhpGitHooks/Infrastructure/Hook/pre-commit .git/hooks

For commit-msg hook:

$ cp vendor/bruli/php-git-hooks/src/PhpGitHooks/Infrastructure/Hook/commit-msg .git/hooks

For pre-push hook:

$ cp vendor/bruli/php-git-hooks/src/PhpGitHooks/Infrastructure/Hook/pre-push .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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
jkarlosb/git-server-docker: Git Server in Docker发布时间:2022-06-11
下一篇:
GitHub · GitHub发布时间:2022-06-11
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap