jeleb-smile / php-git-hooks
Git hooks for PHP projects.
Requires
- php: >=5.6
- beberlei/assert: ^2.5
- bruli/event-bus-bundle: ~0.2
- bruli/ignore-files: ~1.0
- bruli/php-value-objects: ~0.1
- fiunchinho/phpunit-randomizer: ~2.0
- friendsofphp/php-cs-fixer: ^1.11
- mockery/mockery: ~0.9
- mybuilder/phpunit-accelerator: ^1.1
- phpmd/phpmd: ~2.2
- phpunit/php-code-coverage: ~3.0|~4.0
- phpunit/phpunit: ~5.0
- phpunit/phpunit-mock-objects: ~3.0
- seld/jsonlint: 1.3.*
- squizlabs/php_codesniffer: ~2.3
- symfony/config: ~2.7|~3.0
- symfony/dependency-injection: ~2.7|~3.0
- symfony/yaml: ~2.7|~3.0
Requires (Dev)
- composer/composer: ^1.0@dev
- fzaninotto/faker: ^1.6
- v4.11.1
- v4.11
- v4.10
- v4.9
- v4.8.1
- v4.8
- v4.7.1
- v4.7
- v4.6.1
- v4.6
- v4.5.1
- v4.5
- v4.4
- v4.3
- v4.2
- v4.1.6
- v4.1.5
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1
- v4.0
- v3.1.0
- v3.0.0
- dev-master / 2.x-dev
- v2.5.10
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- 1.2-alpha
- 1.1-alpha
- 1.0-alpha
This package is not auto-updated.
Last update: 2025-03-29 23:41:25 UTC
README
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": "~3.0" } }
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
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: 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.
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
- Pablo Braulio (@brulics)
- All contributors
License
php-git-hooks is released under the MIT License. See the bundled LICENSE file for details.