biaoqianwo / yii2-coding-standards
Yii PHP Framework Version 2 - Coding standard tools
Installs: 37
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 49
Type:phpcodesniffer-standard
Requires
- php: >=5.4.0
- squizlabs/php_codesniffer: >=3.0
This package is not auto-updated.
Last update: 2024-11-08 12:26:05 UTC
README
This repository contains settings for Yii2 coding style for various tools.
Getting code
$ php composer.phar install biaoqianwo/yii2-coding-standards
PHP_Codesniffer
PHP_CodeSniffer coding standard, rule set and sniff token parsing classes for the Yii 2 Web Framework. Overally rules are based on PSR-2 standard with some minor exceptions and changes. Rules derived from PSR-2 standard and excluded in Yii2 standard were implemented (or planned to be) as sniff classes.
Rules could also be used for checking code style of an existing Yii2 applications.
Everything that is merged into main Yii2 development repository being checked with these rule set as well.
Using code style
After CodeSniffer is installed you can launch it with custom code style using the following syntax:
$ ./vendor/bin/phpcs --extensions=php --standard=Yii2 /home/resurtm/work/Yii2MegaApp/
If you're using PhpStorm you can configure it to use CodeSniffer using Settings → PHP → Code Sniffer. Yii2 code style can be specified at Inspections → PHP → PHP Code Sniffer validation.
PhpStorm
Yii uses PSR-1 and PSR-2 as code style standards. You can choose these via Settings
→ Code Style
→ PHP
→ Set from...
→ Predefined Style
→ PSR1/PSR2
.