GithubHelp home page GithubHelp logo

nafigator / php-qa-hooks Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 357 KB

Bunch of useful git hooks

License: MIT License

Shell 100.00%
git-hooks php-syntax php code-style code-standard bash-script git git-conflicts

php-qa-hooks's Introduction

GitHub license GitHub release Conventional Commits Semantic Versioning

PHP QA git hooks

Git hooks for PHP commits quality assurance

pre-commit output example

Requirements

  • git
  • bash
  • PHP CLI
  • Core utils

Features

  • Customization by git config options
  • Check for PHP syntax before commit
  • Check for Git conflict markups before commit
  • Warn about PHP dump functions (var_dump(), var_export(), print_r())
  • Check PHP code style before push
  • Run PHPUnit tests before push
  • Colored output

Install via Composer

  1. Install package:

     composer require --dev nafigator/php-qa-hooks
    
  2. Add extra section to composer.json:

     "extra": {
         "scripts-dev": {
             "post-install-cmd": "vendor/nafigator/php-qa-hooks/src/hooks-install.sh"
         }
     }
    
  3. Place phpcs.xml into root of your project.

    NOTE: An example phpcs.xml file can be found in the PHP_CodeSniffer repository: phpcs.xml.dist

  4. Run composer install.

Uninstall

  1. Remove git config section check.php

     git config --remove-section check.php
    
  2. Add extra section to composer.json:

     "extra": {
         "scripts-dev": {
             "post-install-cmd": "vendor/nafigator/php-qa-hooks/src/hooks-uninstall.sh"
         }
     }
    

    Commit and push your changes to repository. When uninstall script completes cleanup for all work copies, move to next step.

  3. Remove package:

     composer remove --dev nafigator/php-qa-hooks
    
  4. Remove phpcs.xml from root ot your project.

Configuration

Example (colors off):

git config check.php.colors false

Available git config options:

check.php.colors [true|false]
check.php.conflicts [true|false]
check.php.dumps [true|false]
check.php.phpunit [true|false]
check.php.style [true|false]
check.php.syntax [true|false]

NOTE: PHPUnit disabled by default. You need to enable it manually.

Versioning

This software follows "Semantic Versioning" specifications. All function signatures declared as public API.

Read more on SemVer.org.

php-qa-hooks's People

Contributors

nafigator avatar phrlog avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dw250100785

php-qa-hooks's Issues

Check syntax changes from commit, not from a file

какой кейс я словил:
я сделал git commit на локале
затем git push
у меня ругнулся php-cs-fixer на отсутствие пустой строки в конце скрипта

я добавил пустую строку, но не сделал git commit с пустой строкой, а минуя это, сразу
git push - php-cs-fixer пропустил и на сервер улетел коммит без пустой последней строки

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.