ivang11 / php-style
PHP-CS-Fixer 的 PHP 风格规则
1.1.1
2020-06-23 23:40 UTC
Requires
- php: ^7.2
- friendsofphp/php-cs-fixer: ^2.8
This package is auto-updated.
Last update: 2024-09-24 09:16:25 UTC
README
这是在我所有项目中应用的标准规则。
安装
您可以使用 composer 从 Packagist 安装。
composer require ivang11/php-style --dev
用法
在您的 .php_cs.dist
配置文件中
<?php // specify the paths to fix $finder = PhpCsFixer\Finder::create() ->notPath('bootstrap/*') ->notPath('storage/*') ->notPath('vendor') ->in([ __DIR__ . '/app', __DIR__ . '/tests', __DIR__ . '/database', ]) ->name('*.php') ->notName('*.blade.php') ->ignoreDotFiles(true) ->ignoreVCS(true); // then call and return the following style function return Ivang11\styles($finder);
为命令创建别名
在 composer.json 中设置命令
"scripts": { "format": [ "vendor/bin/php-cs-fixer fix" ], }
执行命令
composer format
在 CI 中执行
./vendor/bin/php-cs-fixer fix --dry-run
资源
- 在项目和团队间共享 PHP-CS-Fixer 规则。Laravel News 文章
- Laravel Shift 推荐编码规则集。Gist - Shift
许可证
MIT 许可证(MIT)。更多信息请参阅 许可证文件。