You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-32Lines changed: 33 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,9 +33,9 @@ php phpcbf.phar -h
33
33
34
34
### Composer
35
35
If you use Composer, you can install PHP_CodeSniffer system-wide with the following command:
36
-
37
-
composer global require "squizlabs/php_codesniffer=*"
38
-
36
+
```bash
37
+
composer global require "squizlabs/php_codesniffer=*"
38
+
```
39
39
Make sure you have the composer bin dir in your PATH. The default value is `~/.composer/vendor/bin/`, but you can check the value that you need to use by running `composer global config bin-dir --absolute`.
40
40
41
41
Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example:
@@ -49,47 +49,48 @@ Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `
49
49
```
50
50
51
51
You will then be able to run PHP_CodeSniffer from the vendor bin directory:
52
-
53
-
./vendor/bin/phpcs -h
54
-
./vendor/bin/phpcbf -h
55
-
52
+
```bash
53
+
./vendor/bin/phpcs -h
54
+
./vendor/bin/phpcbf -h
55
+
```
56
56
### Phive
57
57
If you use Phive, you can install PHP_CodeSniffer as a project tool using the following commands:
58
-
59
-
phive install phpcs
60
-
phive install phpcbf
61
-
58
+
```bash
59
+
phive install phpcs
60
+
phive install phpcbf
61
+
```
62
62
You will then be able to run PHP_CodeSniffer from the tools directory:
63
-
64
-
./tools/phpcs -h
65
-
./tools/phpcbf -h
66
-
63
+
```bash
64
+
./tools/phpcs -h
65
+
./tools/phpcbf -h
66
+
```
67
67
### PEAR
68
68
If you use PEAR, you can install PHP_CodeSniffer using the PEAR installer. This will make the `phpcs` and `phpcbf` commands immediately available for use. To install PHP_CodeSniffer using the PEAR installer, first ensure you have [installed PEAR](http://pear.php.net/manual/en/installation.getting.php) and then run the following command:
69
-
70
-
pear install PHP_CodeSniffer
71
-
69
+
```bash
70
+
pear install PHP_CodeSniffer
71
+
```
72
72
### Git Clone
73
73
You can also download the PHP_CodeSniffer source and run the `phpcs` and `phpcbf` commands directly from the Git clone:
The default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file against the PEAR coding standard, simply specify the file's location:
83
-
84
-
$ phpcs /path/to/code/myfile.php
85
-
83
+
```bash
84
+
phpcs /path/to/code/myfile.php
85
+
```
86
86
Or if you wish to check an entire directory you can specify the directory location instead of a file.
87
-
88
-
$ phpcs /path/to/code-directory
89
-
87
+
```bash
88
+
phpcs /path/to/code-directory
89
+
```
90
90
If you wish to check your code against the PSR-12 coding standard, use the `--standard` command line argument:
91
-
92
-
$ phpcs --standard=PSR12 /path/to/code-directory
91
+
```bash
92
+
phpcs --standard=PSR12 /path/to/code-directory
93
+
```
93
94
94
95
If PHP_CodeSniffer finds any coding standard errors, a report will be shown after running the command.
0 commit comments