PHP 代码嗅探器include_once错误

2022-08-30 22:12:41

我正在尝试在OS X Mountain Lion上安装PHP CodeSniffer - 但我似乎遇到了一个奇怪的问题

运行“phpcs”时,我收到以下错误:

PHP Warning:  include_once(PHP/CodeSniffer/CLI.php): failed to open stream: No such
file or directory in /usr/lib/php/pear/bin/phpcs on line 31

PHP Warning:  include_once(): Failed opening 'PHP/CodeSniffer/CLI.php' for inclusion
(include_path='.;/usr/lib/php/pear/share/pear/') in /usr/lib/php/pear/bin/phpcs on line 31

PHP Fatal error:  Class 'PHP_CodeSniffer_CLI' not found in /usr/lib/php/pear/bin/phpcs
on line 34

文件 /usr/lib/php/pear/share/pear/PHP/CodeSniffer/CLI.php存在,这让我感到困惑


答案 1

在我的配置中,PHP /路径不是phpcs期望的。我通过创建指向缺失路径的符号链接来解决它。

转到梨目录并运行:

ln -s share/pear/PHP/ PHP

答案 2

我在使用通过Composer安装的PHP CodeSniffer时遇到了此错误。

通过以下方式修复它:

cd /path/to/app
rm -rf vendor/
composer update

推荐