empty-monkey / code-style
Empty Monkey 仓库的代码风格设置
v1.1.0
2022-01-27 08:49 UTC
Requires
- php: 8.0.* | 8.1.*
- friendsofphp/php-cs-fixer: 3.5.0
This package is auto-updated.
Last update: 2024-08-27 14:22:01 UTC
README
此包安装了适用于 Empty Monkey 的 PHP-CS-Fixer。
安装
1. 安装包
composer require --dev empty-monkey/code-style
2. 创建配置文件
在项目的根目录下创建文件 .php-cs-fixer.dist.php
并复制此处的内容
<?php require_once __DIR__ . '/vendor/autoload.php'; $finder = PhpCsFixer\Finder::create() ->in(__DIR__) ->ignoreDotFiles(false) ->name('.php-cs-fixer.dist.php') ->exclude([ 'vendor', 'bootstrap/cache', 'storage', ]) ; $ruleSet = new \EmptyMonkey\CodeStyle\PhpCsFixer\RuleSet\EmptyMonkeySet(); $config = new \EmptyMonkey\CodeStyle\PhpCsFixer\Config(); $config ->setRules($ruleSet->getRules()) ->setFinder($finder) ; return $config;
注意:排除 bootstrap/cache
和 storage
是非常 Laravel 特定的排除项。Empty Monkey 很多地使用了 Laravel,但如果这些行不符合您的需求,您完全可以删除它们。
3. 让运行变得简单
通过向您的 composer.json
中添加此内容来支持您的 composer 通过运行风格。现在您可以通过运行 composer style
来运行所有文件中的风格。
"scripts": { "style": [ "php vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --using-cache=no --config=.php-cs-fixer.dist.php -v" ] }