Yii 2 编码标准
Coding Standard for Yii 2
[!IMPORTANT]
- The minimum required PHP version is PHP
7.4.- The minimum supported PHP_CodeSniffer version is
4.0.2.
The preferred way to install this package is through Composer:
composer require --dev --prefer-dist yiisoft/yii2-coding-standardsTo register the Yii2 ruleset automatically, allow and install the
PHP_CodeSniffer Standards Composer Installer Plugin:
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev dealerdirect/phpcodesniffer-composer-installer:^1.0Check a project with the Yii2 coding standard:
./vendor/bin/phpcs --extensions=php --standard=Yii2 path/to/projectAutomatically fix supported violations with PHP Code Beautifier and Fixer:
./vendor/bin/phpcbf --extensions=php --standard=Yii2 path/to/projectWithout the Composer installer plugin, reference the ruleset by its installed path:
./vendor/bin/phpcs --extensions=php --standard=vendor/yiisoft/yii2-coding-standards/Yii2 path/to/projectYou can also extend the standard from a project-level phpcs.xml or phpcs.xml.dist file:
src
tests
Then run PHP_CodeSniffer without additional arguments:
./vendor/bin/phpcsConfigure PHP_CodeSniffer under Settings → PHP → Quality Tools → PHP_CodeSniffer. Enable the inspection
under Settings → Editor → Inspections → PHP → Quality tools → PHP_CodeSniffer validation, and
select the Yii2 coding standard.
暂无开放 Issues,或尚未同步最近议题。