Skip to content

Commit f8b0214

Browse files
christopher-hopperpfrenssen
authored andcommitted
Issue #2848532 by chOP: Update Composer information in README
1 parent 9233051 commit f8b0214

File tree

1 file changed

+48
-38
lines changed

1 file changed

+48
-38
lines changed

Diff for: README.md

+48-38
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,60 @@ please use [ESLint](http://eslint.org/) and see the
1919
## Installation
2020

2121
First, make sure Composer is installed correctly:
22-
```
23-
which composer
24-
```
22+
23+
which composer
2524

2625
If you get composer not found or similar, follow Composer's installation
2726
instructions.
2827

2928
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`:
3435

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"
4037

4138
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
4561

4662

4763
## Usage
4864

4965
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
5368

5469
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
5872

5973
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
6376

6477

6578
## Working with Editors
@@ -68,31 +81,28 @@ Drupal Code Sniffer can be used with various editors.
6881

6982
Editors:
7083

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)
7690

7791

7892
## Automated Testing (PHPUnit + PHPCS)
7993

8094
Coder Sniffer comes with a PHPUnit test suite to make sure the sniffs work correctly.
8195
Use Composer to install the dependencies:
8296

83-
```
84-
composer install
85-
```
97+
composer install
8698

8799
Then execute the tests:
88-
```
89-
./vendor/bin/phpunit
90-
```
100+
101+
./vendor/bin/phpunit
91102

92103
Then execute the coding standards checker on Coder itself:
93-
```
94-
./vendor/bin/phpcs
95-
```
104+
105+
./vendor/bin/phpcs
96106

97107

98108
## Contributing

0 commit comments

Comments
 (0)