ilyes512 / code-style
一个 PHP_CodeSniffer 风格包。
2.0.0
2024-07-29 19:20 UTC
Requires
- php: ^7.4 || ^8.0
- dealerdirect/phpcodesniffer-composer-installer: ^0.6.2 || ^0.7 || ^1.0
- slevomat/coding-standard: ^8.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-09-29 19:47:18 UTC
README
一个 ECS (Easy Coding Standards) 风格包。
安装
您可以通过 composer 安装此包。
composer require --dev ilyes512/code-style:^2.0
使用方法
将 phpcs.xml
文件添加到您的项目根目录。以下配置示例适用于 Laravel 项目
phpcs.yml
:
<?xml version="1.0"?> <ruleset> <description>A Laravel project coding standard</description> <arg name="extensions" value="php" /> <arg name="report" value="full"/> <arg name="colors"/> <arg value="s"/> <!-- Show sniff codes in report --> <arg value="p"/> <!-- Show progress in report --> <file>.</file> <exclude-pattern>vendor</exclude-pattern> <exclude-pattern>node_modules</exclude-pattern> <exclude-pattern>.phpstan.cache</exclude-pattern> <exclude-pattern>.phpunit.cache</exclude-pattern> <exclude-pattern>bootstrap/cache</exclude-pattern> <exclude-pattern>storage/framework</exclude-pattern> <exclude-pattern>resources/css</exclude-pattern> <exclude-pattern>resources/js</exclude-pattern> <exclude-pattern>coverage</exclude-pattern> <rule ref="Ilyes512CodingStandard"/> </ruleset>
使用 PHPCSStandards 插件
上述配置假设您允许安装 PHP_CodeSniffer 插件。在安装此包时,Composer 将提示您安装它。如果您没有这样做,可以通过将以下内容添加到您的 composer.json 中来允许它:
{ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } } }