fabpot/php-cs-fixer
Composer 安装命令:
composer require --dev fabpot/php-cs-fixer
包简介
A tool to automatically fix PHP code style
README 文档
README
PHP Coding Standards Fixer
The PHP Coding Standards Fixer (PHP CS Fixer) fixes your code to follow the standards.
If you are already using a linter to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. This tool not only detects them, but also fixes them for you.
PHP CS Fixer has built-in rule sets, whether you want to follow PHP coding standards as defined by PHP-FIG's PER Coding Style - @PER-CS,
a wide community like the Symfony - @Symfony,
or our opinionated one - @PhpCsFixer.
You can also define your (team's) style through the configuration file.
PHP CS Fixer can not only unify the style of your code, but also help to modernise your codebase towards
newer PHP (e.g. @autoPHPMigration and @autoPHPMigration:risky) and newer PHPUnit (e.g. @autoPHPUnitMigration:risky).
There are also @auto and @auto:risky that aim to provide good base rules.
Supported PHP Versions
- PHP 7.4 - PHP 8.5
Note
Each new PHP version requires a huge effort to support the new syntax.
That's why the latest PHP version might not be supported yet. If you need it,
please consider supporting the project in any convenient way, for example,
with code contributions or reviewing existing PRs. To run PHP CS Fixer on yet
unsupported versions "at your own risk" - use --allow-unsupported-php-version=yes option.
Documentation
Installation
The recommended way to install PHP CS Fixer is to use Composer:
composer require --dev friendsofphp/php-cs-fixer
## or when facing conflicts in dependencies:
composer require --dev php-cs-fixer/shim
For more details and other installation methods (also with Docker or behind CI), see installation instructions.
Usage
Assuming you installed PHP CS Fixer as instructed above, you can initialise base config for your project by using following command:
./vendor/bin/php-cs-fixer init
To automatically fix your project, or only check against the need of changes, run:
./vendor/bin/php-cs-fixer fix ./vendor/bin/php-cs-fixer check
See usage, list of built-in rules, list of rule sets and configuration file documentation for more details.
If you need to apply code styles that are not built-in into the tool, you can create custom rules.
Editor Integration
Native support exists for:
Community plugins exist for:
Community
The PHP CS Fixer is maintained on GitHub at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer. Contributions, bug reports and ideas about new features are welcome there.
You can reach us in the GitHub Discussions regarding the project, configuration, possible improvements, ideas and questions.
Contribute
The tool comes with quite a few built-in fixers, but everyone is more than welcome to contribute more of them.
fabpot/php-cs-fixer 适用场景与选型建议
fabpot/php-cs-fixer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.51M 次下载、GitHub Stars 达 13.54k, 最近一次更新时间为 2012 年 05 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「static analysis」 「standards」 「fixer」 「Static code analysis」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fabpot/php-cs-fixer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fabpot/php-cs-fixer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fabpot/php-cs-fixer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP_CodeSniffer custom Sniff for Laravel coding standard
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
A set of abstractions that define core services provided by the DVSA
This is the ZooRoyal coding standard.
TwigStan is a static analyzer for Twig templates powered by PHPStan
Vanio Coding Standard Ruleset for PHP_CodeSniffer.
统计信息
- 总下载量: 5.51M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13559
- 点击次数: 29
- 依赖项目数: 850
- 推荐数: 5
其他信息
- 授权协议: MIT
- 更新时间: 2012-05-20