mfonte / coding-standard
Provides multiple rule sets for friendsofphp/php-cs-fixer.
Requires
- php: ^7.4 || ^8.0
- friendsofphp/php-cs-fixer: ^3
Requires (Dev)
- phpspec/prophecy-phpunit: ^1.1
- phpunit/phpunit: ^10
README
Mfonte Coding Standard is a Composer library that provides custom sets of rules for php-cs-fixer to keep our code style consistent across projects.
This library is intended for PHP CS Fixer v3. It will not work with PHP CS Fixer v2.
This library is targeted for projects relying on PHP versions from 7.4 onwards. It will not work with PHP versions below 7.4.
Installation
Use composer
to install mfonte/coding-standard
. php-cs-fixer
v3 is automatically installed.
composer require --dev mfonte/coding-standard
Configuration
Create a configuration file .php_cs.dist
in the root of your project
<?php use Mfonte\CodingStandard\ConfigurationFactory; $config = ConfigurationFactory::fromRuleset(new \Mfonte\CodingStandard\Ruleset\DefaultRuleset()); $config->getFinder()->in(__DIR__); return $config;
The Finder
can be configured to look for PHP files in a single path (as in the example), or in multiple directories.
Is up to you choosing the best configuration based on your project structure.
The caching mechanism of php-cs-fixer
is enabled by default. You have to add .php_cs.cache
to .gitignore
file.
Available Rulesets
DefaultRuleset
- The default ruleset customized as per the package maintainer projectsLaravelRuleset
- The default ruleset for Laravel projectsCmsRuleset
- The default ruleset for CMS projectsWordpressRuleset
- The default ruleset for Wordpress projects
Usage
vendor/bin/php-cs-fixer fix
See php-cs-fixer documentation for all commands and features.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.