3

I am trying to install code sniffer in my localhost but unable to install it.

System: Windows 10

PHP: PHP 5.4+

I have tried below methods.

  1. Open command prompt with administrative permissions (select “run as administrator “)
  2. Go to your php install directory. For example : \wamp\bin\php\php5.5.12
  3. Run this command "pear install PHP_CodeSniffer" OR "pear install --alldeps PHP_CodeSniffer"

Error:

D:\Projects\wamp\bin\php\php5.5.12>pear install PHP_CodeSniffer No releases available for package "pear.php.net/PHP_CodeSniffer" install failed

  1. Then run this command "pear clear-cache" and this also giving error like,

Error:

D:\Projects\wamp\bin\php\php5.5.12>pear clear-cache C:\Users\pcs9\AppData\Local\Temp\pear\cache does not exist or is not a directory

I have to use code sniffer "phpcs" and "phpcbf" but without install PHP_CodeSniffer its not worked.

Please help to resolve this error.

Thanks in advance!

Community
  • 1
  • 1
RJParikh
  • 4,096
  • 1
  • 19
  • 36
  • I'm not sure why PEAR is not working for you on windows (I just tried an install of macOS and it is working) but I wanted to point out that you can also run PHP_CodeSniffer using the PHAR files, or from a Composer install, or straight from a Git clone. If you want to try that out to see if PHPCS is working, the instructions are here: https://github.com/squizlabs/PHP_CodeSniffer#installation – Greg Sherwood Jul 19 '17 at 01:52
  • Ok, Thank you... Actually PEAR is working fine but I am not able to install PHP_CodeSniffer – RJParikh Jul 19 '17 at 04:44

1 Answers1

0

PEAR is not the best way to install PHP packages nowadays.

You could try Composer:

composer require squizlabs/php_codesniffer --dev
Tomas Votruba
  • 23,240
  • 9
  • 79
  • 115