@@ -16,7 +16,7 @@ please use [ESLint](http://eslint.org/) and see the
16
16
[ Drupal ESLint] ( https://www.drupal.org/node/1955232 ) documentation.
17
17
18
18
19
- ## Installation
19
+ ## Global installation
20
20
21
21
First, make sure Composer is installed correctly:
22
22
@@ -25,33 +25,15 @@ First, make sure Composer is installed correctly:
25
25
If you get composer not found or similar, follow Composer's installation
26
26
instructions.
27
27
28
- Install Coder (8.x- 3.x) in your global Composer directory in your home directory
29
- (` ~/.composer ` ):
28
+ Install Coder (8.3.x) in your global Composer directory in your home directory
29
+ (` ~/.config/ composer ` ):
30
30
31
31
composer global require drupal/coder
32
32
33
33
To make the ` phpcs ` and ` phpcbf ` commands available globally, add the Composer
34
34
bin path to your ` $PATH ` variable in ` ~/.profile ` , ` ~/.bashrc ` or ` ~/.zshrc ` :
35
35
36
- export PATH="$PATH:$HOME/.composer/vendor/bin"
37
-
38
-
39
- ### Composer Installer Plugins
40
-
41
- The Coder package (>= 8.2.11) now works with Composer Installer Plugins,
42
- that find and register standards whenever packages are installed or updated.
43
- To use such a plugin within your project, follow these steps.
44
-
45
- composer require --dev drupal/coder
46
-
47
- Now, you will see Drupal and DrupalPractice listed in the available PHP
48
- CodeSniffer standards.
49
-
50
- vendor/bin/phpcs -i
51
-
52
- The same can be done for a Composer global installation.
53
-
54
- composer global require drupal/coder
36
+ export PATH="$PATH:$HOME/.config/composer/vendor/bin"
55
37
56
38
57
39
## Usage
@@ -69,6 +51,21 @@ Automatically fix coding standards
69
51
phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module
70
52
71
53
54
+ ## Local installation in your Drupal project
55
+
56
+ For collaborating developer teams it makes sense to lock a Coder version with
57
+ your other development dependencies locally. In your project where you have your
58
+ composer.json file execute this:
59
+
60
+ composer require --dev drupal/coder
61
+
62
+ Then you can run Coder on your custom module code like this:
63
+
64
+ ./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/custom
65
+
66
+ To simplify execution it is highly recommended to use a settings file, see below.
67
+
68
+
72
69
## Store settings in a phpcs.xml.dist file
73
70
74
71
In order to save and commit your PHPCS settings to Git you can use a
@@ -104,7 +101,9 @@ phpcs.xml.dist file in your project like this:
104
101
105
102
Then you can invoke phpcs without any options and it will read phpcs.xml.dist
106
103
from the current directory. This can also be useful for Continuous Integration
107
- setups.
104
+ setups. Example:
105
+
106
+ ./vendor/bin/phpcs -p
108
107
109
108
110
109
## Working with Editors
0 commit comments