Set the PHP code sniffer to Code Sniffer in Windows 10 64, PHPStorm to verify that your code complies with Yii 2 Web Framework Coding Standard (Yii 2 Web) framework coding standard)
1. Reference URL:https://github.com/yiisoft/yii2-coding-standards, as shown in Figure 1
2. Clone the yiisoft/yii2-coding-standards warehouse, as shown in Figure 2
3. Enter the E:\wwwroot\yii2-coding-standards directory, and execute the installation, as shown in Figure 3
cd .\yii2-coding-standards\
composer install
4. Configure the local PHP interpreter, File | Settings → Languages & Frameworks → PHP → CLI Interpreter drop-down list, as shown in Figure 4
5. CLI interpreters → add → other local. If you already have a local interpreter configured in phpstorm, it will also appear on the menu and the menu item will change to other local, as shown in Figure 5
6. CLI interpreters → add → other local → OK, as shown in Figure 6
7. Configure the local PHP interpreter as local, as shown in Figure 7
8. Select the code sniffer script to use, file | settings → languages & frameworks → php → code sniffer → configuration: The button next to the Local drop-down list, as shown in Figure 8
9. File | Settings → Languages & frameworks → php → code sniffer → php code sniffer path:e:\wwwroot\yii2-coding-standards\vendor\bin\phpcs.bat, as shown in Figure 9
Reference command: ./vendor/bin/phpcs –extensions=php –standard=yii2 /home/resurrtm/work/yii2megaapp/
10. Click the Validate button, if the verification is successful, phpstorm will display the detected code sniffer version information, as shown in Figure 10
11. Configure the local code sniffer script to succeed, as shown in Figure 11
12. Configure the php code sniffer to phpstorm check, file | settings → editor → inspects → php → php code sniffer validation, as shown in Figure 12
13. Yii uses PSR-1 and PSR-2 as the code style standard, File | Settings → Editor → Code style → PHP → set from… → predefined style → PSR1/PSR2, as shown in Figure 13
14. Run the code sniffer in batch mode, code | inspect code → inspect scope: whole project, as shown in Figure 14
15. View the inspection results in the Inspect Results Tool Window, the error and warning reported by the PHP code sniffer have a PHPCS prefix to distinguish it from the PHPStorm internal check, as shown in Figure 15
16. Click Group by Severity (group by severity), you can give priority to the problem of the highest severity, as shown in Figure 16
Server Problem Server Issue
typo typo
info information
weak warning
warning warning
error error
unused entry unused entry















