Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer.

12.0.13 2023-12-07 09:18 UTC

This package is auto-updated.

Last update: 2023-12-07 09:18:18 UTC


Downloads total



Are you already using another tool?


composer require symplify/easy-coding-standard --dev


1. First Run

To start using ECS, just run it:


It will instantly offer to create the ecs.php with your directories from your project.

2. Setup Sets and Checkers

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
    // A. full sets

    // B. standalone rule
    $ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
        'syntax' => 'short',

    // C. dynamics sets

3. Run Again

vendor/bin/ecs check src

The runs above are dry runs, so you can check the code diffs, before they get applied. If you're sure, go for a fix command:

vendor/bin/ecs check src --fix


Configuration can be extended with many options. Here is list of them with example values and little description what are they for:

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ECSConfig $ecsConfig): void {
    $ecsConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']);

        // skip whole rule

        // skip directory by absolute
        __DIR__ . '/packages/Migrations',

        // skip directories by mask
        __DIR__ . '/packages/*/src/Legacy',

        // skip single rule in particular paths
        LineLenghtFixer::class => [
            __DIR__ . '/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php',

    // file extensions to scan [default: [php]]
    $ecsConfig->fileExtensions(['php', 'phpt']);

    // configure cache paths & namespace - useful for Gitlab CI caching, where getcwd() produces always different path
    // [default: sys_get_temp_dir() . '/_changed_files_detector_tests']

    // [default: \Nette\Utils\Strings::webalize(getcwd())']

    // indent and tabs/spaces [default: spaces]

    // end of line [default: PHP_EOL]; other options: "\n"

Parallel Run

ECS runs in X parallel threads, where X is number of your threads.

Do you have 16 threads? That will speed up the process from 2,5 minutes to 10 seconds.

This process is enabled by default. To disable it, use disableParallel() method:

use Symplify\EasyCodingStandard\Config\ECSConfig;

return function (ECSConfig $ecsConfig): void {


How do I clear cache?

vendor/bin/ecs check src --clear-cache

How to load Custom Config?

vendor/bin/ecs check src --config another-config.php


The parallel run is heavily inspired by phpstan/phpstan-src by Ondřej Mirtes. Thank you.