mollie/php-coding-standards
Composer 安装命令:
composer require mollie/php-coding-standards
包简介
Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.
README 文档
README
Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.
Installation
composer require --dev mollie/php-coding-standards
Usage
This package makes use of PHP-CS-Fixer.
Already familiar with PHP-CS-Fixer
This package provides default rules to be used with PHP-CS-Fixer.
You can find them in Mollie\PhpCodingStandards\PhpCsFixer\Rules which has methods specific to php version,
which you can directly use in the ->setRules() part of your config. For example, assuming PHP version 8.3:
use Mollie\PhpCodingStandards\PhpCsFixer\Rules; $config->setRules(Rules::getForPhp83());
New to PHP-CS-Fixer
Place a file named .php-cs-fixer.dist.php that has the following content in your project's root directory.
<?php use Mollie\PhpCodingStandards\PhpCsFixer\Rules; use PhpCsFixer\Config; use PhpCsFixer\Finder; $finder = Finder::create() ->in(__DIR__); return (new Config()) ->setFinder($finder) ->setRiskyAllowed(true) // use specific rules for your php version e.g.: getForPhp74, getForPhp82, getForPhp83 ->setRules(Rules::getForPhp74());
Manual Triggering
Run following command in your project directory, that will run fixer for every .php file.
vendor/bin/php-cs-fixer fix
Use via PhpStorm file watcher
Please follow official PhpStorm documentation
Use via pre-commit git hook
Place a file with the content of the following bash script into .git/hooks directory called pre-commit and make it executable
you can find more details about git hooks on official git manual.
#!/usr/bin/env bash EXCLUDE_DIRECTORIES_REGEX='^(directory_one/(sub_directory_one|sub_directory_two)|directory_two)/.*' git diff --diff-filter=ACMRTUXB --name-only --staged | grep -E '\.php(_cs\.dist)?$' | grep -vE $EXCLUDE_DIRECTORIES_REGEX | while read FILE; do STATUS="$(git status --porcelain ${FILE} | cut -c 1-2)" vendor/bin/php-cs-fixer fix --using-cache=no --quiet --dry-run ${FILE} # Not 0 means php-cs-fixer either errored or wanted to make changes if [ $? != 0 ] then # MM = staged & non-staged modification in same file if [ ${STATUS} = "MM" ] then echo -e "\033[31m┌────────────────────────────────────────────────────────────────────────────────┐" echo -e "│ Failure:\033[39m Codestyle violation(s) in file with both staged and unstaged changes. \033[31m│" echo -e "├────────────────────────────────────────────────────────────────────────────────┘" echo -e "└\033[33m File:\033[39m $FILE" exit 1 fi vendor/bin/php-cs-fixer fix --using-cache=no --quiet ${FILE} git add ${FILE} fi done
Working at Mollie
Mollie is always looking for new talent to join our teams. We’re looking for inquisitive minds with good ideas and strong opinions, and, most importantly, who know how to ship great products. Want to join the future of payments? Check out our vacancies.
License
BSD (Berkeley Software Distribution) License. Copyright (c) 2025, Mollie B.V.
mollie/php-coding-standards 适用场景与选型建议
mollie/php-coding-standards 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68.29k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2019 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mollie/php-coding-standards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mollie/php-coding-standards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 68.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2019-10-18