1
1
Yii 2 Web Framework Coding Standard
2
2
===================================
3
3
4
- This repository contains [ PHP_CodeSniffer] ( https://github.com/squizlabs/PHP_CodeSniffer ) coding standard, rule set
5
- and sniff token parsing classes for the [ Yii 2 Web Framework] ( https://github.com/yiisoft/yii2/ ) . Overally rules
6
- are based on PSR-2 standard with some minor exceptions and changes. Rules derived from PSR-2 standard and excluded
7
- in Yii2 standard were implemented (or planned to be) as sniff classes.
8
-
9
- Rules located in this repository could also be used for checking code style of an existing Yii2 applications.
10
- Everything that is merged into main [ Yii2 development repository] ( https://github.com/yiisoft/yii2 ) being checked
11
- with these rule set as well.
12
-
13
- USAGE
14
- -----
4
+ This repository contains settings for [ Yii2 coding style] ( https://github.com/yiisoft/yii2/wiki/Core-framework-code-style )
5
+ for various tools.
15
6
16
- ### Getting code
7
+ Getting code
8
+ ------------
17
9
18
10
You can get code style definition using one of the following methods.
19
11
@@ -41,6 +33,19 @@ $ php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
41
33
$ php composer.phar install
42
34
```
43
35
36
+ PHP_Codesniffer
37
+ ---------------
38
+
39
+ [ PHP_CodeSniffer] ( https://github.com/squizlabs/PHP_CodeSniffer ) coding standard, rule set
40
+ and sniff token parsing classes for the [ Yii 2 Web Framework] ( https://github.com/yiisoft/yii2/ ) . Overally rules
41
+ are based on PSR-2 standard with some minor exceptions and changes. Rules derived from PSR-2 standard and excluded
42
+ in Yii2 standard were implemented (or planned to be) as sniff classes.
43
+
44
+ Rules could also be used for checking code style of an existing Yii2 applications.
45
+
46
+ Everything that is merged into main [ Yii2 development repository] ( https://github.com/yiisoft/yii2 ) being checked
47
+ with these rule set as well.
48
+
44
49
### Using code style
45
50
46
51
After CodeSniffer is installed you can launch it with custom code style using the following syntax:
@@ -49,20 +54,20 @@ After CodeSniffer is installed you can launch it with custom code style using th
49
54
$ ./vendor/bin/phpcs --extensions=php --standard=Yii2 /home/resurtm/work/Yii2MegaApp/
50
55
```
51
56
52
- 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.
53
-
54
- USEFUL LINKS
55
- ------------
57
+ If you're using PhpStorm you can configure it to use CodeSniffer using Settings → PHP → Code Sniffer.
58
+ Yii2 code style can be specified at Inspections → PHP → PHP Code Sniffer validation.
56
59
57
- PHP_CodeSniffer:
60
+ ### Useful links
58
61
59
62
* [ Configuration options] ( http://pear.php.net/manual/en/package.php.php-codesniffer.config-options.php )
60
63
* [ Manual and guide] ( http://pear.php.net/manual/en/package.php.php-codesniffer.php )
61
64
* [ GitHub repository] ( https://github.com/squizlabs/PHP_CodeSniffer )
62
65
63
- Yii2:
66
+ PhpStorm
67
+ --------
64
68
65
- * [ Coding style] ( https://github.com/yiisoft/yii2/wiki/Core-framework-code-style ) wiki page
69
+ You can import PhpStorm code style settings for Yii2 using File → Import Settings and choosing
70
+ ` PhpStorm/phpstorm_yii2.jar ` .
66
71
67
72
ADDITIONAL NOTES
68
73
----------------
0 commit comments