PHP Coding Standards Fixer 2

(( gitHubWatchers )) (( gitHubStars )) (( gitHubForks ))

The PHP Coding Standards Fixer 2 tool fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents and many more.

If you are already using a linter to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. This tool does not only detect them, but also fixes them for you.


Install from a Brew package (with Brew)


Install it:
brew install homebrew/php/php-cs-fixer

Install from a Composer package as a global CLI utility (with Composer)

Make sure you have Composer installed.

Require it as a global CLI utility:
composer global require friendsofphp/php-cs-fixer
Run it:
Make sure your global vendor binaries directory is in your $PATH environment variable. Check the Composer documentation for more information.

Install from a PHP Archive (with curl or wget)

The PHPUnit documentation has a clear manual on how to install PHARs on Windows.

If you have the Suhosin extension enabled, make sure to allow the execution of PHARs in your php.ini:
suhosin.executor.include.whitelist = phar

Locally (No HTTPS)

Download it:
wget -O php-cs-fixer-v2.phar
curl -sSL -o php-cs-fixer-v2.phar
Use it:
php php-cs-fixer-v2.phar

Globally (No HTTPS)

Download it:
wget -O php-cs-fixer-v2.phar
curl -sSL -o php-cs-fixer-v2.phar
Install it as an executable:
chmod a+x php-cs-fixer-v2.phar
sudo mv php-cs-fixer-v2.phar /usr/local/bin/php-cs-fixer-v2
Use it: