PHP Coding Standards Fixer 2

Author(s)
Fabien Potencier, Dariusz RumiƄski
Website
http://cs.sensiolabs.org/
License
MIT License
GitHub
FriendsOfPHP/PHP-CS-Fixer
Packagist
friendsofphp/php-cs-fixer
DockerHub
phpqa/php-cs-fixer

0 0 0

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.

Installation

Install from a Brew package (with Brew)

Commandline
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:
php-cs-fixer
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 http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar
or
curl -sSL http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -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 http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar
or
curl -sSL http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -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:
php-cs-fixer-v2