focela / php-cs-fixer
Automatically configuration PHP CS Fixer for projects
Installs: 1 714
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- friendsofphp/php-cs-fixer: ^3.0
README
This repository provides a base configuration
for friendsofphp/php-cs-fixer
, which we use to verify and enforce a
single coding standard for PHP code.
Installation
composer require --dev focela/php-cs-fixer
Quick Start
Now that the package is installed, create a configuration file called .php_cs
, .php_cs.php
or .php-cs-fixer.php
at
the root of your project with the following contents:
<?php // Create a new CS Fixer Finder instance $finder = PhpCsFixer\Finder::create()->in(__DIR__); return Focela\PhpCsFixer\Config::create() ->setFinder($finder);
Ignoring files and/or directories
- There will be certain situations where you might want to ignore certain files or directories to not be linted.
- Luckily, this is quite easy to achieve and all you need to do is to perform some calls on the CS Fixer Finder instance :)
- Here's a simple example where we ignore both files and directories:
<?php // Directories to not scan $excludeDirs = [ 'vendor/', ]; // Files to not scan $excludeFiles = [ 'config/app.php', ]; // Create a new CS Fixer Finder instance $finder = PhpCsFixer\Finder::create() ->in(__DIR__) ->exclude($excludeDirs) ->ignoreDotFiles(true) ->ignoreVCS(true) ->filter(function (\SplFileInfo $file) use ($excludeFiles) { return ! in_array($file->getRelativePathName(), $excludeFiles); }); return Focela\PhpCsFixer\Config::create()->setFinder($finder);
Contributing
We encourage and support an active, healthy community of contributors — including you! Details are in the contribution guide and the code of conduct. The php-cs-fixer maintainers keep an eye on issues and pull requests, but you can also report any negative conduct to opensource@focela.com. That email list is a private, safe space; even the php-cs-fixer maintainers don't have access, so don't hesitate to hold us to a high standard.
Released under the MIT License.