@@ -19,47 +19,60 @@ please use [ESLint](http://eslint.org/) and see the
19
19
## Installation
20
20
21
21
First, make sure Composer is installed correctly:
22
- ```
23
- which composer
24
- ```
22
+
23
+ which composer
25
24
26
25
If you get composer not found or similar, follow Composer's installation
27
26
instructions.
28
27
29
28
Install Coder (8.x-2.x) in your global Composer directory in your home directory
30
- (~ /.composer):
31
- ```
32
- composer global require drupal/coder
33
- ```
29
+ (` ~/.composer ` ):
30
+
31
+ composer global require drupal/coder
32
+
33
+ To make the ` phpcs ` and ` phpcbf ` commands available globally, add the Composer
34
+ bin path to your ` $PATH ` variable in ` ~/.profile ` , ` ~/.bashrc ` or ` ~/.zshrc ` :
34
35
35
- To make the phpcs and phpcbf commands available globally, add the composer bin path
36
- to your $PATH variable in ~ /.profile, ~ /.bashrc or ~ /.zshrc:
37
- ```
38
- export PATH="$PATH:$HOME/.composer/vendor/bin"
39
- ```
36
+ export PATH="$PATH:$HOME/.composer/vendor/bin"
40
37
41
38
Register the Drupal and DrupalPractice Standard with PHPCS:
42
- ```
43
- phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
44
- ```
39
+
40
+ phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
41
+
42
+
43
+ ### Composer Installer Plugins
44
+
45
+ The Coder package (>= 8.2.11) now works with Composer Installer Plugins,
46
+ that find and register standards whenever packages are installed or updated.
47
+ To use such a plugin within your project, follow these steps.
48
+
49
+ composer require --dev dealerdirect/phpcodesniffer-composer-installer
50
+ composer require --dev drupal/coder
51
+
52
+ Now, you will see Drupal and DrupalPractice listed in the available PHP
53
+ CodeSniffer standards.
54
+
55
+ vendor/bin/phpcs -i
56
+
57
+ The same can be done for a Composer global installation.
58
+
59
+ composer global require dealerdirect/phpcodesniffer-composer-installer
60
+ composer global require drupal/coder
45
61
46
62
47
63
## Usage
48
64
49
65
Check Drupal coding standards
50
- ```
51
- phpcs --standard=Drupal /file/to/drupal/example_module
52
- ```
66
+
67
+ phpcs --standard=Drupal /file/to/drupal/example_module
53
68
54
69
Check Drupal best practices
55
- ```
56
- phpcs --standard=DrupalPractice /file/to/drupal/example_module
57
- ```
70
+
71
+ phpcs --standard=DrupalPractice /file/to/drupal/example_module
58
72
59
73
Automatically fix coding standards
60
- ```
61
- phpcbf --standard=Drupal /file/to/drupal/example_module
62
- ```
74
+
75
+ phpcbf --standard=Drupal /file/to/drupal/example_module
63
76
64
77
65
78
## Working with Editors
@@ -68,31 +81,28 @@ Drupal Code Sniffer can be used with various editors.
68
81
69
82
Editors:
70
83
71
- * Eclipse: https://www.drupal.org/node/1420004
72
- * Komodo: https://www.drupal.org/node/1419996
73
- * Netbeans: https://www.drupal.org/node/1420008
74
- * Sublime Text: https://www.drupal.org/node/1419996
75
- * vim: https://www.drupal.org/node/1419996
84
+ - [ Eclipse] ( https://www.drupal.org/node/1420004 )
85
+ - [ Komodo] ( https://www.drupal.org/node/1419996 )
86
+ - [ Netbeans] ( https://www.drupal.org/node/1420008 )
87
+ - [ PhpStorm] ( https://www.jetbrains.com/help/phpstorm/php-code-sniffer.html )
88
+ - [ Sublime Text] ( https://www.drupal.org/node/1419996 )
89
+ - [ Vim] ( https://www.drupal.org/node/1419996 )
76
90
77
91
78
92
## Automated Testing (PHPUnit + PHPCS)
79
93
80
94
Coder Sniffer comes with a PHPUnit test suite to make sure the sniffs work correctly.
81
95
Use Composer to install the dependencies:
82
96
83
- ```
84
- composer install
85
- ```
97
+ composer install
86
98
87
99
Then execute the tests:
88
- ```
89
- ./vendor/bin/phpunit
90
- ```
100
+
101
+ ./vendor/bin/phpunit
91
102
92
103
Then execute the coding standards checker on Coder itself:
93
- ```
94
- ./vendor/bin/phpcs
95
- ```
104
+
105
+ ./vendor/bin/phpcs
96
106
97
107
98
108
## Contributing
0 commit comments