I followed the installing docs in PHP_CodeSniffer both via composer and Pear but I still have issues running it globally and I get:
~ phpcs
zsh: command not found: phpcs
I'am using MAC OS 10.13.5 and my config looks like:
~ which php
/usr/bin/php
~ php -v
PHP 7.1.16 (cli) (built: Apr 1 2018 13:14:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
~ which composer
/usr/local/bin/composer
~ composer --version
Composer version 1.6.5 2018-05-04 11:44:59
~ pear list -a
Installed packages, channel __uri:
==================================
(no packages installed)
Installed packages, channel doc.php.net:
========================================
(no packages installed)
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.4.3 stable
Console_Getopt 1.4.1 stable
PEAR 1.10.5 stable
PHP_CodeSniffer 3.3.0 stable
Structures_Graph 1.1.1 stable
XML_Util 1.4.2 stable
Installed packages, channel pecl.php.net:
=========================================
(no packages installed)
I fixed this by not using the PEAR (it is outdated anyways) and instead used composer. In composer I had the issue that the bin directory is not on the $PATH so I added it and wrote a blog about it: http://www.numediaweb.com/php-code-beautifier-phpstorm/1616
You figured this out before I got to it, but it is possible that your PEAR bin_dir wasn't in $PATH either. You can see that dir by running pear config-get bin_dir.
I think the documentation needs an update regarding the $PATH issue.
Second thing, PEAR package should not be maintained anymore as we now have composer. Many big libraries moved out of Pear since 2014..
I fixed this by not using the PEAR (it is outdated anyways) and instead used composer. In composer I had the issue that the bin directory is not on the $PATH so I added it and wrote a blog about it: http://www.numediaweb.com/php-code-beautifier-phpstorm/1616
@numediaweb Why your website block request from Tor?! I can not check your blog post...
I also tried to install PHP_CodeSniffer globally using Composer, with
composer global require "squizlabs/php_codesniffer=*"
and after adding ~/.composer/vendor/bin/ to my $PATH, phpcs is still not found. I fear this may be to do with .zsh shell.
I also tried using composer exec [args...] as a way to access phpcs without appending the $PATH, but this does not seem to be working as it should.
Anyone finding this just as difficult as me? Ive spent days on and off trying to battle this.
Any ideas?
I also tried to install PHP_CodeSniffer globally using Composer, with
composer global require "squizlabs/php_codesniffer=*"and after adding
~/.composer/vendor/bin/to my $PATH, phpcs is still not found. I fear this may be to do with .zsh shell.I also tried using
composer exec [args...]as a way to access phpcs without appending the $PATH, but this does not seem to be working as it should.Anyone finding this just as difficult as me? Ive spent days on and off trying to battle this.
Any ideas?
Same issue here, did you solve it?
Same issue. Changing the PATH entry from using ~/.composer/vendor/bin to the full value /home/<user>/.composer/vendor/bin fixed it.
Or, you can add this to your PATH: $(composer global config bin-dir --absolute)
That will add the correct path for you.
Same issue. Changing the PATH entry from using
~/.composer/vendor/binto the full value/home/<user>/.composer/vendor/binfixed it.Or, you can add this to your PATH:
$(composer global config bin-dir --absolute)That will add the correct path for you.
worked for me, thanks
/home/<user>/.composer/vendor/bin worked for me.
$(composer global config bin-dir --absolute) generates an error at login.
Ubuntu 18.04
Composer version 1.9.3 2020-02-04 12:58:49
Most helpful comment
Same issue. Changing the PATH entry from using
~/.composer/vendor/binto the full value/home/<user>/.composer/vendor/binfixed it.Or, you can add this to your PATH:
$(composer global config bin-dir --absolute)That will add the correct path for you.