The Easiest Way to Use Any Coding Standard

Downloads total



  • Blazing fast Parallel run
  • Use PHP_CodeSniffer || PHP-CS-Fixer - anything you like
  • 2nd run under few seconds with un-changed file cache
  • Skipping files for specific checkers
  • Prepared sets - PSR12, Symfony, arrays, use statements, spaces and more... - see SetList class for all
  • Prefixed version by default to allow install without conflicts

Are you already using another tool?


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


1. Create Configuration and Setup Checkers

  • Create an ecs.php in your root directory
  • Add Sniffs
  • ...or Fixers you'd love to use
// ecs.php
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
    // A. full sets

    // B. standalone rule
    $services = $containerConfigurator->services();
        ->call('configure', [[
            'syntax' => 'short',

Full Sets before Standalone Rules

It is highly recommended to imports sets (A) first, then add standalone rules (B).

The reason for this is that some settings are configured in the full sets too, and will therefore overwrite your standalone rules, if not configured first.

2. Run in CLI

# dry
vendor/bin/ecs check src

# fix
vendor/bin/ecs check src --fix


How to load own config?

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


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 Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();

    // alternative to CLI arguments, easier to maintain and extend
    $parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);

    // run single rule only on specific path
    $parameters->set(Option::ONLY, [
        ArraySyntaxFixer::class => [__DIR__ . '/src/NewCode'],

    $parameters->set(Option::SKIP, [
        // skip paths with legacy code
        __DIR__ . '/packages/*/src/Legacy',

        ArraySyntaxFixer::class => [
            // path to file (you can copy this from error report)
            __DIR__ . '/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php',

            // or multiple files by path to match against "fnmatch()"
            __DIR__ . '/packages/*/src/Command',

        // skip rule completely

        // just single one part of the rule?
        ArraySyntaxFixer::class . '.SomeSingleOption',

        // ignore specific error message
        'Cognitive complexity for method "addAction" is 13 but has to be less than or equal to 8.',

    // scan other file extendsions; [default: [php]]
    $parameters->set(Option::FILE_EXTENSIONS, ['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']
    $parameters->set(Option::CACHE_DIRECTORY, '.ecs_cache');

    // [default: \Nette\Utils\Strings::webalize(getcwd())']
    $parameters->set(Option::CACHE_NAMESPACE, 'my_project_namespace');

    // indent and tabs/spaces
    // [default: spaces]
    $parameters->set(Option::INDENTATION, 'tab');

    // [default: PHP_EOL]; other options: "\n"
    $parameters->set(Option::LINE_ENDING, "\r\n");

Parallel Run

Do you have multi-core CPUs? ECS can run in X parallel threads, where X is number of your threads. E.g. with laptop with AMD Ryzen 4750U it is 16.

That means 1600 % faster run with same amount of analysed files. Did you code base took 16 minutes to fix? Now it's 1 minute.

How to enable it?

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();

    $parameters->set(Option::PARALLEL, true);

Coding Standards in Markdown


How to correct PHP snippets in Markdown files?

vendor/bin/ecs check-markdown
vendor/bin/ecs check-markdown docs/

# to fix them, add --fix
vendor/bin/ecs check-markdown docs/ --fix

Do you have already paths defined in ecs.php config? Drop them from CLI and let ECS use those:

vendor/bin/ecs check-markdown --fix


How can I see all loaded checkers?

vendor/bin/ecs show
vendor/bin/ecs show --config ...

How do I clear cache?

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

Report Issues

In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker


The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.


The parallel run is package is heavily inspired by by OndΕ™ej Mirtes. Thank you.

Easy Coding Standard

[READ-ONLY] The Easiest way to start using PHP CS Fixer and PHP_CodeSniffer with 0-knowledge

Easy Coding Standard Info

⭐ Stars 862
πŸ”— Homepage
πŸ”— Source Code
πŸ•’ Last Update 6 months ago
πŸ•’ Created 5 years ago
🐞 Open Issues 0
βž— Star-Issue Ratio Infinity
😎 Author symplify