Installation | Command line installer |
Installation | |
PEAR Manual | |
Both pear and pecl tools should be available everywhere on command line. For that to work, pear's binary directory should be in your PATH variable.
To verify it works, simply type pear. A list of commands should be shown:
|
You should further test that PEAR is up to date:
|
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's php_dir must be a part of PHP's include path.
First, check where PEAR installs .php files:
|
Now it's time to find which configuration file is used by your PHP installation. On command line, execute:
|
To see which php.ini is used by PHP on your web server, create a file with only phpinfo(); in it and load it in your browser.
Now check PHP's include_path setting on command line:
|
To check the PHP's include_path in your web server, save a file with only phpinfo(); in it. Open it in your browser and verify the setting.
In every case, PEAR's php_dir should be in the include path. If not, add it in your system's php.ini.
Now that this is done, try including a file. Create a new .php file with the following contents:
|
System.php is shipped with every PEAR installation and thus should be on your computer, too. Open the file with the browser from your web server, and also try it on command line. There should be no output. A message like:
|
means that your include path is not correct.
That's it! Now go on and install some packages.
After changing php.ini, you need to restart your web server.
Newer Linux distributions use multiple php.ini files; mostly one for the web server (e.g. /etc/php/apache2-php5/) and one for command line (like /etc/php/cli-php5/). Make sure you edit the right ones.
On Windows, recent versions of PHP use php.ini from their own directory (where php.exe is). You still might have an old php.ini in your windows or system(32) directory that fools you.
You cannot get away with using absolute paths in your own require_once() statements as an altervative to fixing your include_path, because all the other files that are then required by your scripts are all coded for relative pathing based on include_path.
Installation | Command line installer |
Installation | |
PEAR Manual | |