There is no license information available for the latest version (dev-main) of this package.

Easy Coding Standard configurations for Craft CMS projects





Installs: 101 688

Dependents: 258

Suggesters: 0

Security: 0

Stars: 16

Watchers: 5

Forks: 5

Open Issues: 3

dev-main 2022-06-30 16:27 UTC

This package is auto-updated.

Last update: 2024-06-29 05:11:57 UTC


Easy Coding Standard config for Craft CMs

This package provides Easy Coding Standard configurations for Craft CMS plugins and projects.

In general, we follow the PSR-12 coding style guide, with a couple alterations:

  • Multi-line function argument rules aren’t enforced. (¶4.4)
  • Spaces after the function keyword aren’t enforced. (¶7)
  • Visibility is not enforced for constants, for Craft 3 projects.

To install, run the following commands within your plugin or project:

composer config minimum-stability dev
composer config prefer-stable true
composer require craftcms/ecs:dev-main --dev

Then add an ecs.php file to the root of your plugin or project:



use craft\ecs\SetList;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function(ECSConfig $ecsConfig): void {
        __DIR__ . '/src',

    $ecsConfig->sets([SetList::CRAFT_CMS_3]); // for Craft 3 projects
    $ecsConfig->sets([SetList::CRAFT_CMS_4]); // for Craft 4 projects

Adjust the PATHS value to include all source/test code locations, and remove the appropriate SetList option, depending on whether this is for Craft 3 or Craft 4.

With that in place, you can check your plugin/project’s code with the following command:

vendor/bin/ecs check

And to automatically fix it as well, pass the --fix argument:

vendor/bin/ecs check --fix

You might also want to define check-cs and fix-cs scripts in composer.json:

  "...": "...",
  "scripts": {
    "check-cs": "ecs check --ansi",
    "fix-cs": "ecs check --ansi --fix"

Then you could execute ECS using composer run-script:

composer run-script check-cs
composer run-script fix-cs