[PHP]: Coding style fixer

This tool will automatically fix your PHP code style. You can run it manually, or set it as pre-commit hook and it will run automatically.

Installation

composer require friendsofphp/php-cs-fixer

Usage:

Default configuration will apply PSR1 and PSR2 rules. To run the default configuration:
If you would like to apply specific rules, you can set the rules argument of these command.

--dry-run lets you run the fixer without making changes.
--diff will output all the changes made by the fixer.

If you want to set the configuration statically in the codebase to be used by developers as a guideline, you can add this file to the root directory. When detected php-cs-fixer will apply the rules defined there. .php_cs.dist

References:
Github repository: https://github.com/friendsofphp/php-cs-fixer
Composer: https://packagist.org/packages/friendsofphp/php-cs-fixer

Majd Arbash

Leave a Reply