12

I want to configure multiple installed paths for phpcs.

I can add one via:

phpcs --config-set installed_paths the/dir/to/standard

I tried adding multiple by using : yet it did not work and the man page is non-existent and the help not that helpful.

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
  • Docs are here: https://github.com/squizlabs/PHP_CodeSniffer/wiki , and the specific doc you need is here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths – Greg Sherwood Jun 19 '15 at 10:47

3 Answers3

27

Use a comma-separated list without spaces between the paths:

phpcs --config-set installed_paths first/path/,second/path/,yet/another/path/
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
  • Just to note, on Windows I put quotations around the paths as some had spaces in them. For e.g. `phpcs --config-set installed_paths "C:\Users\XXXX\AppData\Roaming\Composer\vendor\drupal\coder\coder_sniffer,C:\Users\XXXX\AppData\Roaming\Composer\vendor\something\else\here"` – Daniel Dewhurst Nov 04 '19 at 10:18
  • Using `$(pwd)` worked for me (WordPress and CodeIgniter): `~ phpcs --config-set installed_paths $(pwd)/.composer/codeigniter4-standard,$(pwd)/.composer/wpcs` – Pabamato Jan 24 '20 at 16:03
2

I have the same frustration about not being able to set multiple paths. I use a bash script to append the current path to the installed_paths:

phpcs_ipath=$(phpcs --config-show installed_paths); oldpath=${phpcs_ipath##*:}; phpcs --config-set installed_paths ${oldpath},$(pwd)

I cd into the directory that contains my new standards, then run this one-liner. It grabs the current paths and appends the current path to them. Not perfect, but it's a quick way to add paths.

Morgan Estes
  • 223
  • 3
  • 16
1

In addition to using a comma (,) as a separator, if you're on a Unix shell, do not use ~/.... Use $HOME/... or use the actual path (e.g. /home/nabil/...).

~/... won't work

phpcs --config-set installed_paths ~/path_1,~/path_2

$HOME/... or the actual path (e.g. /home/nabil/...) will work

phpcs --config-set installed_paths $HOME/path_1,$HOME/path_2
phpcs --config-set installed_paths /home/nabil/path_1,/home/nabil/path_2
Nabil Kadimi
  • 10,078
  • 2
  • 51
  • 58