Code Monkey home page Code Monkey logo

pre-commit's Introduction

Pre commit hook

Checks in our pre-commit hook

  • Syntax check with php lint (“php -l”): We check every committed file has a valid PHP syntax.
  • Sync check of composer.json and composer.lock files: We check these two files are committed together in order to avoid committing the json but not the lock and generate some issue to another developers.
  • PHP CS Fixer check: With the –dry-run parameter it does not fix, just say what the problems are. With the –fixers parameter you can control what fixers you want to execute.
  • PHP Code Sniffer check: Same as before, but another rule that checks another rules.
  • PHPMD: We have enabled the controversial rules.
  • Unit Testing check: We run around 3.000 tests right now.

PHPCsFix

PHPLint

PHPUnit

INSTALLATION:

The recommended way to install this library is through Composer:

add juizmill/pre-commit as a composer dependency.

composer.json

"require-dev": {
    ...
    "juizmill/pre-commit": "dev-master"
}

php composer.phar update juizmill/pre-commit

USAGE:

When a developer clones the project, it just needs to:

Edit composer.json and add:

    "scripts": {
        "pre-update-cmd": "PreCommit\\Composer\\Script\\Hooks::preHooks",
        "pre-install-cmd": "PreCommit\\Composer\\Script\\Hooks::preHooks",
        "post-update-cmd": "PreCommit\\Composer\\Script\\Hooks::postHooks",
        "post-install-cmd": "PreCommit\\Composer\\Script\\Hooks::postHooks"
    }

or

    cd [project]
    rm -rf .git/hooks/pre-commit
    cp vendor/juizmill/pre-commit/hooks/pre-commit .git/hooks/pre-commit
    chmod -R 777 .git/hooks/pre-commit

Remembering to set up the hooks

Custom config

Copy arquives vendor/juizmill/pre-commit/config/* to [project]

Reference

Write your git hooks in PHP and keep them under git control

PHP_CodeSniffer

PHP-CS-FIX

PHPMD

Custom PHPCS and PHPMD

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.