$ ./vendor/bin/phpcs backend / controllers / AdvertisingController.php --colors
ERROR: the "Yii" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend
"require-dev": {
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-coding-standards": "2.*"
}
Затем создайте файл phpcs.xml.dist вкорневой каталог проекта, см. PHP_CodeSniffer Документация: Использование файла конфигурации по умолчанию
<?xml version="1.0"?>
<ruleset name="Yii2 App Basic Standard">
<description>Yii2 App Basic coding standard</description>
<exclude-pattern>/runtime/*</exclude-pattern>
<exclude-pattern>/web/assets/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/requirements.php</exclude-pattern>
<rule ref="vendor/yiisoft/yii2-coding-standards/Yii2"/>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>/migrations/*</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>/migrations/*</exclude-pattern>
</rule>
</ruleset>
$ ./vendor/bin/phpcs backend/controllers/AdvertisementController.php --colors
ОШИБКА: стандарт кодирования "Yii" не установлен.Установленные стандарты кодирования: MySource, PEAR, PSR1, PSR12, PSR2, Squiz и Zend
"require-dev": {
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-coding-standards": "2.*"
}
Далее создайте файл phpcs.xml.dist
в корневом каталоге проекта, см. PHP_CodeSniffer
Документация:Использование файла конфигурации по умолчанию
<?xml version="1.0"?>
<ruleset name="Yii2 App Basic Standard">
<description>Yii2 App Basic coding standard</description>
<exclude-pattern>/runtime/*</exclude-pattern>
<exclude-pattern>/web/assets/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/requirements.php</exclude-pattern>
<rule ref="vendor/yiisoft/yii2-coding-standards/Yii2"/>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>/migrations/*</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>/migrations/*</exclude-pattern>
</rule>
</ruleset>
Последнее, используйте команду:
php composer.phar install --dev
vendor/bin/phpcs --encoding=utf-8 --extensions=php .
Это привело меня к ошибке vendor / bin / phpcs --encoding =utf-8 --extensions = php.
coding standard is not installed. The installed coding standards are
MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend
Как я могу установить Yii2 в качестве стандарта кодирования