2

I'm attempting to install PHP Code Sniffer for PhpStorm, but have been unable to get it to work. I've been following the steps here: https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm

I added PHP Code Sniffer as a Composer dependency, and it now appears in the project directory. I then went to the code sniffer settings page, where I entered the path to the PHPCS.bat file. When I click Validate, I get an error message saying "Can not run PHP Code Sniffer".

screenshot of error

Have I missed a step or is there a log somewhere with more information on what is not working?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Titan9251
  • 35
  • 1
  • 6
  • What `idea.log` has to say about this (Help | Show Log in...)? Any exceptions/errors there? Will that `phpcs.bat` work if you run it manually outside the IDE? – LazyOne Aug 17 '17 at 14:30
  • Nothing in the idea log. It runs if I click on it in explorer, but not sure how to check if it is running properly. – Titan9251 Aug 17 '17 at 14:47
  • what if you select just phpcs instead of phpcs.bat? – Dmitrii Aug 18 '17 at 12:07

2 Answers2

1

I solved the same problem by editing the phpcs.bat file and replacing the paths:

PHPBIN=@php_bin@

with

PHPBIN=path\to\php.exe

and

"%PHPBIN%" "@bin_dir@\phpcs" %*

with

"%PHPBIN%" "path\to\phpcs" %*

0

I had the same issue, I solve it adding the php path to the PATH environment variables on windows. Because when it runs the scripts needs to run php and if it not present on the global path of windows will fail.