mito/coding-standards
Composer 安装命令:
composer require mito/coding-standards
包简介
Mito coding standards
README 文档
README
This repository contains Mito's coding standards for PHP based applications.
Getting the code
You can get code style definition using one of the following methods.
- Clone
hellowearemito/php-coding-standardsrepository:
$ git clone git://github.com/hellowearemito/php-coding-standards.git
- Install using composer:
$ composer require mito/coding-standards:"^3.0"
PHP_Codesniffer
This repository contains five phpcs standards:
Application: for normal class files.Views: for view files, requires using curly braces for control structures.ViewsAlternate: for view files, requires using alternate syntax for control structures.ViewsMixed: for view files, allows both curly braces and alternate syntax.Others: for other files, such as configuration files and migration classes.
These standards are based on PSR-12, with some additions and improvements.
The Views standards disable some rules that cause problems when mixing php with html,
and therefore cannot fully check view files and cannot fix all problems in them,
so be careful when using phpcbf with view files.
For a full description of the rules, see docs/rules.md.
Using the standards
After CodeSniffer is installed, you can launch it with a custom standard using the following syntax:
$ ./vendor/bin/phpcs --extensions=php --standard=vendor/mito/coding-standards/Application .
To automatically fix most issues, use phpcbf:
$ ./vendor/bin/phpcbf --extensions=php --standard=vendor/mito/coding-standards/Application .
Warning: always check phpcbf's output and keep backups. If it breaks your code, you get to keep both pieces.
You should also run a syntax check using php -l before running phpcbf,
because some sniffs assume the code is syntactically valid, and may mangle it if it is not.
If you're using PhpStorm you can configure it to use CodeSniffer using Settings → PHP → Code Sniffer. The standard can be specified at Inspections → PHP → PHP Code Sniffer validation.
Note that this will check all your files with a single standard, but you should use different standards
for different types of files.
These standards were designed for use with gulp-phpcs and gulp-phpcbf,
so instead of using exclusion patterns in the ruleset.xml, they rely on the gulp task selecting
the appropriate standard for a file.
You can write your own ruleset.xml that extends from the Application standard
and contains appropriate exclusion patterns (check the Others and Views ruleset.xml files for what rules to exclude).
Useful links
Contributing
See CONTRIBUTING.md for information.
mito/coding-standards 适用场景与选型建议
mito/coding-standards 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.41k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 09 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phpcs」 「codesniffer」 「coding standards」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mito/coding-standards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mito/coding-standards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mito/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
Appocular PHP coding standard, PHP Code Sniffer rules.
CodeSniffer ruleset for the Superbrave coding standard
Coding standard to Norsys PHP projects
统计信息
- 总下载量: 6.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-09-05