PHP Code Beautifier and Fixer
- Author(s)
- (( authors ))
- Company
- (( companies ))
- (( resource.label ))
- (( resource.mask ))
- Dependencies
- (( dependencies ))
PHP Code Beautifier and Fixer fixes violations of a defined coding standard.
PHP Code Beautifier and Fixer is part of a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.
Installation
Install from a Composer package as a dev dependency (with Composer)
Make sure you have Composer installed.
composer require --dev squizlabs/php_codesniffer
Run it:
php vendor/bin/phpcbf
Install from a Composer package as a global CLI utility (with Composer)
Make sure you have Composer installed.
composer global require squizlabs/php_codesniffer
Run it:
phpcbf
Make sure your global vendor binaries directory is in your $PATH environment variable. Check the Composer documentation for more information.
Install from a Git repository (with Git)
Make sure you have git installed.
git clone git://github.com/squizlabs/PHP_CodeSniffer.git
Change into the new directory:
cd PHP_CodeSniffer
Run it:
bin/phpcbf
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
Download it:wget -O phpcbf.phar https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
or
curl -sSL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar -o phpcbf.phar
Use it:
php phpcbf.phar
Globally
Download it:wget -O phpcbf.phar https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
or
curl -sSL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar -o phpcbf.phar
Install it as an executable:
chmod a+x phpcbf.phar
sudo mv phpcbf.phar /usr/local/bin/phpcbf
Use it:
phpcbf