Easy Coding Standard

Easy Coding Standard (ECS) is a tool for PHP that integrates popular linters and code formatters to help enforce coding standards and maintain a consistent code style across your project. It automatically analyzes your code against predefined standards, flagging issues and even fixing them when possible to ensure a high level of code quality.

Using ECS reduces the manual effort required to format code and resolve style issues, allowing developers to focus more on building functionality. It promotes a uniform codebase that adheres to agreed-upon guidelines, ultimately improving readability, maintainability, and overall project quality.

Foster Commerce Package

Example config

TODO setup and link to a repo that has code quality tooling

User guide

https://github.com/easy-coding-standard/easy-coding-standard

Usage

Note: ECS changes are relatively safe and are generally cleanup/formatting type changes. It is still recommended to review any changes made by ECS before committing.

In a PHP app/website

We typically use DDEV for local development of PHP apps or websites. As such, ECS should be run from within ddev.

To check for formatting changes, run:

ddev composer run-script ecs:check

To apply any fixes use:

ddev composer run-script ecs:fix

In a PHP package

When working on a PHP package, such as a Craft plugin, we typically use composer directly, not from inside ddev. ECS can be run directly, instead of from within ddev.

To check for formatting changes, run:

composer run-script ecs:check

To apply any fixes use:

composer run-script ecs:fix