Skip to content

Commit cd33789

Browse files
authored
Update README.md
1 parent 091e6bd commit cd33789

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,19 @@ For Win OS you should be using `\` as separator:
6969
vendor\bin\sniff -v
7070
```
7171

72-
#### Hook it into your IDE for live-correction
73-
You can easily make a "watcher" for your IDE, so any file you work on, will be auto-corrected when (auto-)saving.
74-
For PHPStorm, for example, make sure you switch `Show Console` to `never` to not be disturbed by it all the time.
72+
#### Include it in your IDE via hotkey
73+
E.g. for PHPStorm:
74+
* Open Settings -> Tools -> External Tools
75+
* Add a new tool named "cs-sniffer" and set Program to `$ProjectFileDir$/vendor/bin/phpcs`, Parameters to `--standard=$ProjectFileDir$/vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml -p $FilePath$` and Working directoy to `$ProjectFileDir$`.
76+
* Add a new tool named "cs-fixer" and set Program to `$ProjectFileDir$/vendor/bin/phpcbf`, Parameters to `--standard=$ProjectFileDir$/vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml -v $FilePath$` and Working directoy to `$ProjectFileDir$`.
77+
* Optionally uncheck "Open console" if you don't want to see any output here for the fixer.
78+
* Now set up your hotkeys under Settings -> Keymap (search for cs-sniffer and cs-fixer). E.g. `Control + Comma` for sniffing, and `Control + Dot` for fixing.
79+
80+
##### Hook it into your IDE for live-correction
81+
You can also easily make a "watcher" for your IDE, so any file you work on, will be auto-corrected when (auto-)saving.
82+
But here you should better only whitelist certain sniffs that only add things and don't remove anything.
83+
84+
Note: For PHPStorm, for example, make sure you switch `Show Console` to `never` to not be disturbed by it all the time.
7585

7686
### Writing new sniffs
7787
You can contribute by adding new sniffs as per PSR-2-R standard.

0 commit comments

Comments
 (0)