rugaard/git-hooks-php

PHP related Git hooks.

1.0.0 2022-02-17 10:21 UTC

This package is auto-updated.

Last update: 2024-10-17 16:19:51 UTC


README

This is a "plugin" package which seamlessly integrates with the Git Hooks package.

It will install git hooks, that will automatically run multiple checks on your projects PHP files, to make sure they do not contain errors and follow the expected coding standards.

📦 Installation

You install the package via Composer by using the following command:

composer require rugaard/git-hooks rugaard/git-hooks-php

📝 Configuration

To change the default configuration of one or more script, you need to have a git-hooks.config.json file in your project root. If you don't, you can create it with the following command:

./vendor/bin/git-hooks config

Rugaard\GitHooks\PHP\Hooks\PreCommit\PhpCodeStyleCommand

Checks all staged .php files for coding style errors.

Note: By default, if a valid config has not been provided, this command will look for phpcs.xml or phpcs.xml.dist as an alternative.

If it finds any of those options, the above paramters will be ignored, and the configuration file will take priority.

Rugaard\GitHooks\PHP\Hooks\PreCommit\PhpLintCommand

Checks all staged .php files for syntax errors.

Script has nothing to configure

Rugaard\GitHooks\PHP\Hooks\PreCommit\PhpStaticAnalysisCommand

Statically analyzes all (or staged) .php files for errors.

Note: By default, if a valid config has not been provided, this command will look for phpstan.neon or phpstan.neon.dist as an alternative.

If it finds any of those options, the above paramters will be ignored, and the configuration file will take priority.

Rugaard\GitHooks\PHP\Hooks\PrePush\PhpTestSuiteCommand

Runs the projects test suite(s).

* Requires pest to be installed in your project

Note: By default, if a valid config has not been provided, this command will look for phpunit.xml or phpunit.xml.dist as an alternative.

If it finds any of those options, the above paramters will be ignored, and the configuration file will take priority.

🚓 License

This package is licensed under MIT.