gomzyakov / php-cs-fixer-config
Code style configuration for `php-cs-fixer` based on PSR-12.
Package info
github.com/gomzyakov/code-style
Type:package
pkg:composer/gomzyakov/php-cs-fixer-config
Requires
- php: ^8.3
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.62
- mockery/mockery: ^1.6
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0
This package is auto-updated.
Last update: 2026-06-03 04:50:12 UTC
README
This package allows sharing identical php-cs-fixer formatting rules across all of your projects without copy-and-pasting configuration files.
Quickstart
Step 1 of 3
Install friendsofphp/php-cs-fixer & this package via Composer:
composer require --dev friendsofphp/php-cs-fixer gomzyakov/code-style
Step 2 of 3
Then create file .php-cs-fixer.dist.php at the root of your project with following contents:
<?php use Gomzyakov\CodeStyleFinder; use Gomzyakov\CodeStyleConfig; // Routes for analysis with `php-cs-fixer` $routes = ['./src', './tests']; return CodeStyleConfig::createWithFinder(CodeStyleFinder::createWithRoutes($routes));
Change the value of $routes depending on where your project's source code is.
Step 3 of 3
And that's it! You can now find code style violations with following command:
./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run
And then completely fix them all with:
./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php
Configuration
You must pass a set of routes to the CodeStyleFinder::createWithRoutes() call. For example, for Laravel projects, this would be:
CodeStyleFinder::createWithRoutes(['./app', './config', './database', './routes', './tests'])
Also, you can pass a custom set of rules to the CodeStyleConfig::createWithFinder() call:
CodeStyleConfig::createWithFinder($finder, [ '@PHP81Migration' => true, 'array_indentation' => false ])
Support
If you find any package errors, please, make an issue in current repository.
License
This is open-sourced software licensed under the MIT License.