Verifying the include path
To use PEAR and PEAR compatible packages in your applications, you normally include them into your PHP scripts using require_once(). For this to work, PEAR'sphp_dir
must be a part of PHP's include path.
-
First, check where PEAR installs
.php
files:$ pear config-get php_dir /usr/share/lib/php/
This directory will contain
System.php
. -
Now it's time to find which configuration file is used by your PHP installation. On command line, execute:
$ php --ini Configuration File (php.ini) Path: /etc/php/cli-php5 Loaded Configuration File: /etc/php/cli-php5/php.ini Scan for additional .ini files in: /etc/php/cli-php5/ext-active Additional .ini files parsed: /etc/php/cli-php5/ext-active/php_gtk2.ini, /etc/php/cli-php5/ext-active/xdebug.ini
To see which
php.ini
is used by PHP on your web server, create a file with only<?php phpinfo(); ?>
as the contents, and save it in your local web root ascheck_php.php
. Open the file in your browser ashttp://localhost/check_php.php
, to find the path to thephp.ini
file your web server is using. -
Now check PHP's include_path setting on command line:
$ php -c /path/to/php.ini -r 'echo get_include_path()."\n";'
To check PHP's include_path in your web server, create a file with only
<?php phpinfo(); ?>
as the contents, and save it in your local web root ascheck_php.php
. Open the file in your browser ashttp://localhost/check_php.php
, to verify the include_path your web server is using.In every case, PEAR's
php_dir
should be in the include path. If not, add it in your system'sphp.ini
.
这里特别要注意,如果你用的wamp,实际在起作用的php.ini并不是在php文件夹下,而是在apache里
;***** Added by go-pear
include_path=".;C:\Users\lein\pear"
;*****