Code Sniffer error in PHPStorm

Answered

Hello

 I have a problem when I am trying to use Code Sniffer (3.1.1) in PHPStorm (2017.2.4) on Windows 10. I receive the following error message:

phpcs: '"@php_bin@"' is not recognized as an internal or external command,
operable program or batch file.
Exclude register_file.php from PHP Code Sniffer analysis.

From an earlier post on the subject results that I should edit a certain file, but it is not very explicit where should the edit occur and what exactly I should edit. I have added the link to this post:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000317164-Error-adding-CodeSniffer-to-PHPStorm-php-bin-is-not-recognized-as-an-internal-or-external-command-operable-program

Any help or indication will be appreciated!

Many thanks!,

Lucian

0
4 comments
Avatar
Permanently deleted user

Hello,

You configured your Code Sniffer to be launched via BAT file - this is the file you need to edit.

0
Avatar
Permanently deleted user

The file phpcs.bat has the following content:

@echo off
REM PHP_CodeSniffer detects violations of a defined coding standard.
REM
REM @author Greg Sherwood <gsherwood@squiz.net>
REM @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
REM @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence

if "%PHPBIN%" == "" set PHPBIN=@php_bin@
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "@bin_dir@\phpcs" %*

What I have to edit here? I cannot figure it our by myself!

Thanks

0
Avatar
Permanently deleted user

After I have installed pear the error message have changed into this:

PHP Code Sniffer
phpcs: Could not open input file: @bin_dir@\phpcs
Exclude account.php from PHP Code Sniffer analysis.

0
Avatar
Permanently deleted user

I have solved it by replacing in the phpcs.bat file this line: "%PHPBIN%" "@bin_dir@\phpcs" %*

with this line "%PHPBIN%" "C:/absolute path to bat file/phpcs" %*

Everything goes fine now!

0

Please sign in to leave a comment.