0

I've tried all kinds of fixes to get php_codesniffer working with OSX and Pear and am having no luck. The installation works, the scripts are there, but when I run, for example, phpcs -h, nothing happens.

I am doing the following to install and try to run:

chris@DEATHSTAR:~$ pear clear-cache
reading directory /var/folders/r5/3s2lsmc10zj07nw56xbx1k1m0000gn/T//pear/cache
14 cache entries cleared
chris@DEATHSTAR:~$ pear install php_codesniffer
Unknown remote channel: pear.phpunit.de
Did not download optional dependencies: channel://pear.phpunit.de/PHP_Timer, use --alldeps to download automatically
pear/PHP_CodeSniffer can optionally use package "channel://pear.phpunit.de/PHP_Timer"
downloading PHP_CodeSniffer-1.4.6.tgz ...
Starting to download PHP_CodeSniffer-1.4.6.tgz (402,882 bytes)
.................................................................................done: 402,882 bytes
install ok: channel://pear.php.net/PHP_CodeSniffer-1.4.6
chris@DEATHSTAR:~$ which phpcs
/Applications/MAMP/bin/php/php5.4.10/bin/phpcs
chris@DEATHSTAR:~$ phpcs -h
chris@DEATHSTAR:~$

The PHP directory is correct in Pear config:

chris@DEATHSTAR:~/.vim$ pear config-show | grep php_bin
PHP CLI/CGI binary             php_bin          /Applications/MAMP/bin/php/php5.4.10/bin/php

Not sure what else I can do to troubleshoot?

Possible related note: PHP Mass Detector does essentially the same thing...it installs correctly, but running it seemingly does nothing as well!

Chris
  • 871
  • 1
  • 10
  • 19

1 Answers1

1

I think the phpcs binary file is not inside your $PATH. Use the follow steps to figure out if this is true:

  1. Call the codesniffer on your command line with entering the full path:
    $ /Applications/MAMP/bin/php/php5.4.10/bin/phpcs -h If you get the help output then proceed with step 2. If not something else is broken in your setup.
  2. Export this path to $PATH:
    $ export PATH=$PATH:/Applications/MAMP/bin/php/php5.4.10/bin/phpcs
  3. Call the CodeSniffer like you try before:
    $ phpcs -h
  4. To make this change permanent you need to insert the command from 2. into you .profile/.bashrc/.zshrc or whatever you use as a shell
common sense
  • 3,775
  • 6
  • 22
  • 31
  • Something is definitely broken in my config. $ which pear /Applications/MAMP/bin/php/php5.4.19/bin/pear $ which phpcs $ pear install php_codesniffer pear/php_codesniffer is already installed and is the same as the released version 1.5.2 install failed $ locate phpcs /Users/mgifford/pear/bin/phpcs /Users/mgifford/pear/bin/scripts/phpcs-svn-pre-commit /Users/mgifford/pear/phpcs /Users/mgifford/pear/scripts/phpcs-svn-pre-commit $ /Users/mgifford/pear/bin/phpcs -h Warning: include_once(PHP/CodeSniffer/CLI.php): ... Nothing relevant in $ pear config-show – Mike Gifford Mar 22 '14 at 15:07