Git Product home page Git Product logo

php-cs-fixer-pre-commit-hook's Introduction

PHP-CS-Fixer Pre-Commit Hook

Run PHP-CS-Fixer before committing code in a Git pre-commit hook.

The fixer runs quietly without making changes to your files, but will stop and print analysis upon first file that needs to be fixed. Only changed files since the last commit are checked, unless configuration files have changed, in which case the fixer runs a full check.

The hook is invoked by git commit, and can be bypassed using the --no-verify option:

git commit --no-verify

Environment variables

  • PHP_CS_FIXER_IGNORE_ENV=1
  • XDEBUG_MODE=off

Installation

Run the installer.

./install

You'll thank me later ;)

Manual installation

Create the hooks directory and set the Git hooks path.

mkdir ~/.githooks && git config --global core.hooksPath ~/.githooks

Download, copy, or symlink the pre-commit script to ~/.githooks/pre-commit-php and ensure the file is executable. The installer symlinks the script into the githooks folder.

chmod 744 ~/.githooks/pre-commit-php

Create a pre-commit script that calls the php-cs-fixer pre-commit and any local pre-commit script if it exits.

#!/bin/sh

if [ -f ~/.githooks/pre-commit-php ]; then
    exec ~/.githooks/pre-commit-php
fi

if [ -f .git/hooks/pre-commit ]; then
    exec .git/hooks/pre-commit
fi

License

Released under the GPL-3.0-or-later License.

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.