2012-10-30 55 views
0

我已经安装了梨和使用sudo php_beautifier ...PHP_Beautifier - 致命错误 - 需要对PEAR.php

从我读过,我应该能够使用命令

php_beautifier x.php 

格式化代码但是,当我尝试这样做,我得到这个错误:

Warning: require_once(PEAR.php): failed to open stream: No such file or directory in /Users/philip/pear/bin/php_beautifier on line 37 

Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:') in /Users/philip/pear/bin/php_beautifier on line 37 

我已经看了看php_beautifier.php代码,我不知道什么是错的。第37行:

require_once 'PEAR.php'; 

并且该文件与pear.php位于相同的目录中?

+0

'whereis'对PEAR.php在什么位置? –

+0

@SalmanA Ahh我的坏,我有梨,但不是pear.php在我的文件夹中。只是复制梨的一个版本并将其命名为pear.php在同一文件夹中安全吗? – Philip

+1

也许你不需要。做一个'php -i> phpinfo.txt',打开文件并记下'include_path'的值。如果它包含有效的'/ path/to/the/folder/that/contains/PEAR.php',那么问题就在其他地方。否则,你只需要在php.ini文件中添加/编辑路径。 –

回答

2

理想情况下,PEAR目录的路径应在php.ini中的include_path指令中指定。这使您可以轻松地在代码中加入PEAR的核心和包,例如:

require_once 'PEAR.php'; 
require_once 'Console/Getopt.php'; 

否则,您必须指定到PEAR目录,这使得你的代码的可移植性完整路径:

require_once '/usr/share/pear/PEAR.php'; 
require_once '/usr/share/pear/Console/Getopt.php'; 

要探测include_path指令的有效值,请使用phpinfo()函数。如果不包含路径PEAR安装,使用方法:

# UNIX 
include_path = ".:/path/to/pear" 
# Windows 
include_path = ".;C:\path\to\pear" 

更详细和一步一步的instructions can be found here

0

打开/private/etc/php.ini

而替换该行(796):

;include_path = ".:/php/includes" 

到:

​​
相关问题