Coder Social home page Coder Social logo

git-hooks-php's Introduction

๐Ÿช Git Hooks for PHP GitHub Actions (tests)

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.

Parameter Description Default
encoding Encoding of the files being checked utf-8
hideWarnings Hide code style warnings true
onlyStaged Only check code style on staged PHP files. true
paths Paths to directories/files that should be checked. Only used when onlyStaged is set to false. []
config Path to custom configuration file. null

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.

Parameter Description Default
level Level of strictness to use. From 0 to 9. 8
onlyStaged Only analyze staged PHP files. true
paths Only the following directories/files should be checked. []
memory-limit Set memory limit of process. Fx. 512M for 512 MB. null
config Path to custom configuration file. null

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

Parameter Description Default
driver Application to run test suite(s). Supports: phpunit or pest* phpunit
printer Change printer used by driver application \\NunoMaduro\\Collision\\Adapters\\Phpunit\\Printer
config Path to custom configuration file null

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

git-hooks-php's People

Contributors

rugaard avatar

Watchers

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