fattureincloud/php-code-standard
Composer 安装命令:
composer require fattureincloud/php-code-standard
包简介
PHP CS Fixer coding standard, extended from @PhpCsFixer.
README 文档
README
PHP CS Fixer coding standard, extended from @PhpCsFixer.
Prerequisites
You need to install PHP CS Fixer installed locally in the project and husky + lint-staged configured in order to make all of this working properly.
Install PHP CS Fixer
composer require friendsofphp/php-cs-fixer --dev
Install husky + lint-staged
Create a package.json like this one:
{
"description": "For automation purposes",
"license": "MIT",
"devDependencies": {
"husky": "^4.2.5",
"lint-staged": "^10.2.7"
},
"lint-staged": {},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
Run npm install.
Add these lines to composer.json:
"scripts": {
...
"post-install-cmd": "npm_config_loglevel=silent npm install",
"post-update-cmd": "npm_config_loglevel=silent npm install",
...
}
Finally, remember to add node_modules/ to .gitignore.
Installation and usage
composer require fattureincloud/php-code-standard --dev
Add lint-staged action
Put this line as lint-staged action in package.json in order to execute PHP CS Fixer on all the staged files at commit time.
"lint-staged": {
...
"*.php": "php ./vendor/bin/php-cs-fixer fix --allow-risky=yes --config ./vendor/fattureincloud/php-code-standard/.php-cs-fixer.php"
...
},
Add composer script (optional)
Add the following line under composer.json scripts property.
"scripts": {
...
"php-cs-fixer": "./vendor/bin/php-cs-fixer --allow-risky=yes --config=./vendor/fattureincloud/php-code-standard/.php-cs-fixer.php"
...
}
PHPStorm
Enable inspections
- Search for "PHP CS Fixer" under Quality Tools
- Add a local configuration with path
$PROJECT_DIR$/vendor/friendsofphp/php-cs-fixer/php-cs-fixer - Search for "PHP CS Fixer validation" under Inspections
- Flag "Allow ricky rules"
- Select Custom ruleset
- Click on the 3 dots and enter
<your-project-directory>/vendor/fattureincloud/php-code-standard/.php-cs-fixer.php
Configure file watcher
Create a file watcher with the following values:
Name: php-cs-fixer
File type: PHP
Scope: Current File
Program: $ProjectFileDir$/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
Arguments: fix --allow-risky=yes --config=$ProjectFileDir$/vendor/fattureincloud/php-code-standard/.php-cs-fixer.php $FileDir$/$FileName$
Output paths to refresh: $FileDir$/$FileName$
De-flag all the advanced options.
Configure external tool (optional)
Create an external tool with the following values:
Name: Run PHP CS Fixer
Description: Run PHP CS Fixer
Group: External Tools
Program: $ProjectFileDir$/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
Arguments: fix --allow-risky=yes --config=$ProjectFileDir$/vendor/fattureincloud/php-code-standard/.php-cs-fixer.php --verbose $FilePath$
Working directory: $ProjectFileDir$
Flag Synchronize files after execution and Open console for tool output.
VSCode
TODO
fattureincloud/php-code-standard 适用场景与选型建议
fattureincloud/php-code-standard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.51k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fattureincloud/php-code-standard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fattureincloud/php-code-standard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-03