1. Reference URL: https://github.com/yiisoft/yii2-coding-standards , as shown in Figure 1

2. Clone the yiisoft/yii2-coding-standards repository, as shown in Figure 2

3. Navigate to the E:\wwwroot\yii2-coding-standards directory and run the installation, as shown in Figure 3
cd .\yii2-coding-standards\
composer install

4. Configure the local PHP interpreter by clicking the button next to the File | Settings → Languages & Frameworks → PHP → CLI Interpreter drop-down list, as shown in Figure 4

5. CLI Interpreters → Add → Other Local. If you have already configured a local interpreter in PhpStorm, it will also appear in the menu, and the menu item will change to Other Local, as shown in Figure 5

6. CLI Interpreters → Add → Other Local → Local → OK, as shown in Figure 6

7. Set the local PHP interpreter to Local, as shown in Figure 7

8. Select the code sniffer script to use by clicking the button next to the File | Settings → Languages & Frameworks → PHP → Code Sniffer → Configuration: 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/resurtm/work/Yii2MegaApp/

10. Click the Validate button. If validation passes successfully, PhpStorm will display the detected code sniffer version information, as shown in Figure 10

11. The local code sniffer script is successfully configured, as shown in Figure 11

12. Configure the PHP code sniffer as a PhpStorm inspection: File | Settings → Editor → Inspections → PHP → PHP Code Sniffer validation, as shown in Figure 12

13. Yii uses PSR-1 and PSR-2 as code style standards: 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 → Inspection scope: Whole project, as shown in Figure 14

15. View the inspection results in the Inspection Results Tool Window. Errors and warnings reported by the PHP code sniffer have the phpcs prefix to distinguish them from PhpStorm’s internal inspections, as shown in Figure 15

16. Click Group by Severity to prioritize resolving the highest severity issues, as shown in Figure 16
Server problem
Typo
Info
Weak Warning
Warning
Error
Unused entry

