2012-11-01 71 views
2

我試過使用pear安裝codesniffer,但是我的mac無法識別phpcs命令。codesniffer命令在幾次安裝和升級後未被識別

梨配置

Configuration (channel pear.php.net): 
===================================== 
Auto-discover new Channels  auto_discover 1 
Default Channel    default_channel pear.php.net 
HTTP Proxy Server Address  http_proxy  <not set> 
PEAR server [DEPRECATED]  master_server pear.php.net 
Default Channel Mirror   preferred_mirror pear.php.net 
Remote Configuration File  remote_config <not set> 
PEAR executables directory  bin_dir   /usr/local/pear/bin 
PEAR documentation directory doc_dir   /usr/local/pear/docs 
PHP extension directory  ext_dir   /opt/local/lib/php/extensions/no-debug-non-zts-20090626 
PEAR directory     php_dir   /usr/local/pear/share/pear 
PEAR Installer cache directory cache_dir  /private/tmp/pear/cache 
PEAR configuration file  cfg_dir   /usr/local/pear/cfg 
directory 
PEAR data directory   data_dir   /usr/local/pear/data 
PEAR Installer download  download_dir  /tmp/pear/install 
directory 
PHP CLI/CGI binary    php_bin   /opt/local/bin/php 
php.ini location    php_ini   /opt/local/etc/php5/php.ini-development 
--program-prefix passed to  php_prefix  <not set> 
PHP's ./configure 
--program-suffix passed to  php_suffix  <not set> 
PHP's ./configure 
PEAR Installer temp directory temp_dir   /tmp/pear/install 
PEAR test directory   test_dir   /usr/local/pear/tests 
PEAR www files directory  www_dir   /usr/local/pear/www 
Cache TimeToLive    cache_ttl  3600 
Preferred Package State  preferred_state stable 
Unix file mask     umask   22 
Debug Log Level    verbose   1 
PEAR password (for    password   <not set> 
maintainers) 
Signature Handling Program  sig_bin   /usr/local/bin/gpg 
Signature Key Directory  sig_keydir  /opt/local/etc/pearkeys 
Signature Key Id    sig_keyid  <not set> 
Package Signature Type   sig_type   gpg 
PEAR username (for    username   <not set> 
maintainers) 
User Configuration File  Filename   /Users/anthonygordon/.pearrc 
System Configuration File  Filename   /opt/local/etc/pear.conf 

我檢查php_bin和PHP可執行文件是存在的。

當我運行phpcs我得到command not found

我用盡升級梨,卸載重裝代碼嗅探器,應有盡有。當我運行安裝目錄,我得到

梨列表

Package   Version State 
Archive_Tar  1.3.10 stable 
Console_Getopt 1.3.1 stable 
PEAR    1.9.4 stable 
PHP_CodeSniffer 1.4.0 stable 
Structures_Graph 1.0.4 stable 
XML_Util   1.2.1 stable 

回答

7

的phpcs腳本應該是bin_dir裏面,所以在/usr/local/pear/bin/phpcs所以只要確保該文件存在第一。如果沒有,安裝出現問題。

看看你能不能直接運行:如果輸出PHPCS幫助php /usr/local/pear/bin/phpcs -?

,然後PHPCS安裝正確,問題可能是你的$ PATH。運行echo $PATH並確保/usr/local/pear/bin顯示在那裏。如果沒有,你可以修改你的路徑設置,或者你可以配置PEAR把可執行腳本放在別的地方。

例如,您的$ PATH可能已經包括/usr/local/bin(如我的Mac一樣),所以你可以改變bin_dir到:

pear uninstall php_codesniffer 
pear config-set bin_dir /usr/local/bin 
pear install php_codesniffer 

現在再次嘗試phpcs命令。

+0

您的解決方案爲我工作的一半。我可以至少看到一些我可以修復的錯誤,謝謝你的步驟 –

相關問題