Posted on May 27, 2014, 8:55 am by about-dev.com
I was curious to see how can I use PEAR packages with a PHP application so I installed PEAR on my WAMP server which was very easy. The hard part was to make it work that's way I'm writting this post to present you the steps I had to follow.
Step 1: install PEAR on WAMP server
In CLI go to the path where you have installed PHP on the WAMP sever, for me is C:\wamp\bin\php\php5.4.12. Here you should have the
go-par.phar file. If this file is not here you should get it from here and save it in the path where you have installed PHP and then run the following command:
>>cd C:\wamp\bin\php\php5.4.12 C:\wamp\bin\php\php5.4.12>>go-pear.phar
After that the installlation process should begin an you can press Enter on every question to accept the default settings.
Step 2: add PEAR installation path to your PATH environment
For that you should open the installation folder, C:\wamp\bin\php\php5.4.12, using Windows Explorer and double click the PEAR by typing the following command
instead of typing:
Step 3: restart the WAMP server
Now you should see the PEAR installation path in the from the file. If this has not happend, you can set it by changing that directive from php.ini to this one:
include_path = ".;c:\wamp\bin\php\php5.4.12\pear;"
Then you have to restart the WAMP server and after that you can use PEAR on the WAMP server.
Step 4: test the installation of PEAR on the WAMP server
C:\wamp>>>pear install Net_UserAgent_Detect
This should install the Net_UserAgent_Detect PEAR package and you can use this in a PHP script like this:
require_once( "Net/UserAgent/Detect.php"); $detect = new Net_UserAgent_Detect(); echo "You are running ".$detect->getBrowserString();