joomla/cms-coding-standards
最新稳定版本:2.0.0-alpha2
Composer 安装命令:
composer require joomla/cms-coding-standards
包简介
Extended Joomla Coding Standards for the Joomla CMS application
README 文档
README
The Joomla project has migrated all its code to use PSR-12 codestyle instead of a custom version. If you are using this codestyle, you should also migrate to PSR-12. This codestyle will not get any further maintenance and is therefore archived since March 2024.
cms-coding-standards
Extended Joomla Coding Standards definition for use in the Joomla CMS environment
This repository includes the Joomla CMS coding standard definition for PHP Codesniffer. The PHP_CodeSniffer standard will never be 100% accurate, but should be viewed as a strong set of guidelines while writing software for Joomla.
See Joomla coding standards documentation at https://developer.joomla.org/coding-standards.html
If you want to contribute and improve this documentation, you can find the source files in the manual section of the master branch https://github.com/joomla/coding-standards/tree/master/manual
Requirements
- PHP 5.3+
- PHP Codesniffer 2.9+ or
- PHP 5.6+
- PHP Codesniffer 3.3.0+
Installation via Composer
Add "joomla/cms-coding-standards": "~1.0" to the require-dev block in your composer.json and then run composer install.
{ "require-dev": { "joomla/cms-coding-standards": "~1.0" } } Alternatively, you can simply run the following from the command line:
composer global require squizlabs/php_codesniffer "~2.8" composer require joomla/cms-coding-standards "~1.0"
Running
You can use the installed Joomla standard like:
phpcs --standard=Joomla-CMS path/to/code Alternatively if it isn't installed you can still reference it by path like:
phpcs --standard=path/to/joomla/cms-coding-standards path/to/code Selectively Applying Rules
NOTE: this should be an exact copy of the "Selectively Applying Rules" section of the main Joomla Coding Standards README and is here only for reference
For consuming packages there are some items that will typically result in creating their own project ruleset.xml, rather than just directly using the Joomla ruleset.xml. A project ruleset.xml allows the coding standard to be selectivly applied for excluding 3rd party libraries, for consideration of backwards compatability in existing projects, or for adjustments necessary for projects that do not need php 5.3 compatability (which will be removed in a future version of the Joomla Coding Standard in connection of the end of php 5.3 support in all active Joomla Projects).
For information on selectivly applying rules read details in the PHP CodeSniffer wiki
Common Rule Set Adjustments
The most common adjustment is to exclude folders with 3rd party libraries, or where the code has yet to have coding standards applied.
<!-- Exclude folders not containing production code --> <exclude-pattern type="relative">build/*</exclude-pattern> <exclude-pattern type="relative">tests/*</exclude-pattern> <!-- Exclude 3rd party libraries. --> <exclude-pattern type="relative">libraries/*</exclude-pattern> <exclude-pattern type="relative">vendor/*</exclude-pattern>
Another common adjustment is to exclude the camelCase format requirement for "Classes, Functions, Methods, Regular Variables and Class Properties" the essentially allows for B/C with snake_case variables which were only allowed in the context of interacting with the database.
<rule ref="Joomla"> <exclude name="Joomla.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/> <exclude name="Joomla.NamingConventions.ValidVariableName.NotCamelCaps"/> <exclude name="Joomla.NamingConventions.ValidVariableName.MemberNotCamelCaps"/> <exclude name="Joomla.NamingConventions.ValidFunctionName.FunctionNoCapital"/> </rule>
Old Protected method names were at one time prefixed with an underscore. These Protected method names with underscores are depreceated in Joomla projects but for B\C reasons are still in the projects. As such excluding the MethodUnderscore sniff is a common ruleset adjustment
<rule ref="Joomla"> <exclude name="Joomla.NamingConventions.ValidFunctionName.MethodUnderscore"/> <exclude name="Joomla.NamingConventions.ValidVariableName.ClassVarHasUnderscore"/> </rule>
Using example rulesets that Selectively Applying Rule
You have to tell you can tell PHPCS where the example ruleset folder is (i.e. install them in PHPCS)
phpcs --config-set installed_paths /path/to/joomla/coding-standards/Example-Rulesets
Note: the composer scripts will run when the standard is installed globally, but not when it's a dependancy. As such, you may want to run PHPCS config-set. When you run PHPCS config-set it will always overwrite the previous values. Use --config-show to check previous values before using --config-set So instead of overwriting the existing paths you should copy the existing paths revealed with --config-show and add each one seperated by a comma: phpcs --config-set installed_paths [path_1],[path_2],[/path/to/joomla-coding-standards],[/path/to/joomla/coding-standards/Example-Rulesets]
joomla/cms-coding-standards 适用场景与选型建议
joomla/cms-coding-standards 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 89.74k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「joomla」 「phpcs」 「coding standards」 「php codesniffer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 joomla/cms-coding-standards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joomla/cms-coding-standards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 joomla/cms-coding-standards 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Vanio Coding Standard Ruleset for PHP_CodeSniffer.
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
CodeSniffer ruleset for the ZettaCMS coding standard
CodeSniffer ruleset for the Superbrave coding standard
Joomla Preload Package
SAM Code Sniffer Standards
统计信息
- 总下载量: 89.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-01-04