craftcms/ecs
Composer 安装命令:
composer require craftcms/ecs
包简介
Easy Coding Standard configurations for Craft CMS projects
README 文档
README
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
functionkeyword 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:
<?php declare(strict_types=1); use craft\ecs\SetList; use Symplify\EasyCodingStandard\Config\ECSConfig; return static function(ECSConfig $ecsConfig): void { $ecsConfig->parallel(); $ecsConfig->paths([ __DIR__ . '/src', __FILE__, ]); $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
craftcms/ecs 适用场景与选型建议
craftcms/ecs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 228.81k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 craftcms/ecs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 craftcms/ecs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 228.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 23
- 依赖项目数: 379
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2026-01-04