Closed bubifengyun closed 8 years ago
You can add yiisoft/yii2-coding-standards
on composer.json
:
"require-dev": {
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-coding-standards": "2.*"
}
Next, create a phpcs.xml.dist
file on the project root directory, see PHP_CodeSniffer Documentation: Using a Default Configuration File
<?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>
Last, use command:
php composer.phar install --dev
vendor/bin/phpcs --encoding=utf-8 --extensions=php .
Thank you, i had solved this problem. I used XAMPP, and set
sudo ln -s /opt/lampp/bin/php /usr/local/bin/php
sudo ln -s /opt/lampp/bin/pear /usr/local/bin/pear
installed the PHPCodeSniffer, and find the folder /opt/lampp/lib/php/PHP/CodeSniffer/Standards/_
So, I copy Yii2 folder from this project to the above folder. That is
/opt/lampp/lib/php/PHP/CodeSniffer/Standards
Yii2/{ruleset.xml,Sniffs}
PSR2
<many standards>
Then, Yii2 can be used like PSR2 and Zend. Thank you.
I am so sorry that YII 2 coding standard is not installed. I cannot understand the Getting code. I installed phpcs in my /opt/lampp/bin/phpcs. my network is located in /opt/lampp/htdocs/www/wuzhishan/
this code from README.md
what the last Yii2MegaApp means? is it an app? Thank you.