Install PEAR and PEAR packages

This article is for those who don’t have PEAR framework installed with WAMP or XAMPP servers and want to install it, especially to send email using either WAMP Server 2.0c or older versions.

While reading and following this article, replace the Apache’s and PHP’s version numbers with what your system have.

(Skip this paragraph if you don’t want to know about PEAR and want to go directly to the installation steps.) From PEAR’s page: “PEAR is a framework and distribution system for reusable PHP components”. PEAR has many useful libraries to make various web operations easy. Authentication, Date-Time, Encryption, File Formats and Compression, Images, eMail, Math, Number, Captcha, Validation, Streams, Web Services are few of the categories for which lots of packages are available to use freely. However there are extensive information about them but there is no useful documentation is available on their website about installing PEAR. PEAR is not bundled with older WAMP Server versions; so here are the steps to install PEAR on localhost/WAMP Server. It should also work with XAMPP.

  1. Create a backup of copy of the “index.php” file of your WAMP Server located at “C:\wamp\www” folder, PEAR installer will replace this file.
  2. Open php.ini file (“Taskbar WAMP Icon -> PHP -> php.ini” OR “C:\wamp\bin\apache\Apache2.2.17\bin\php.ini”), search for “error_reporting” setting and set it to “E_ALL & ~E_DEPRECATED”.
  3. Enable “php_sockets” and “php_openssl” extensions of PHP:
  4. Enable “ssl_module” module of Apache:
  5. Create a folder named “pear” inside “C:\wamp\bin\php\php5.2.6” folder.
  6. Click this link http://pear.php.net/go-pear; a PHP Script file will be shown.
  7. Press Ctrl + S to save the file. Give “go-pear.php” name to it and save it in the “C:\wamp\www” folder.
  8. Click this link http://localhost/go-pear.php to start setup of PEAR.
  9. In the page, click on “Next>>”, “Packages” page will be shown.
  10. In “Configurations” section, set “Installation Prefix ($prefix)” to “C:\wamp\bin\php\php5.2.6\pear”.
  11. You may set “C:\wamp\bin\php\php5.2.6” for the 11th option “php.exe path, optional (CLI command tools)”.
  12. You may select “PEAR_Frontend_Gtk2” and “MDB2” optional packages too for installation.
  13. Then click on “Install” button. The installation will begin and would download about 4-5 MB of data.
  14. After installation finish, open “php.ini” file, search for “include_path” setting. If there is a semicolon (;) at the beginning of the line, remove it to uncomment the line. Append “;C:\wamp\bin\php\php5.2.6\pear\PEAR” in the include path.
  15. Restart all services of WAMP Server.
  16. Open “http://localhost“. You should see PEAR installer page instead of WAMP Server’s default “index.php”; PEAR installer modifies this file and it will avail the WebFront (web application) of PEAR management. You can view and add more PEAR packages by clicking on the “list all packagenames” link.
  17. Now you have 2 ways to install the required PEAR packages (MIME_Type, Mail, Mail_Mime, Net_SMTP, Net_Socket), using the WebFront or using the “pear.bat” with Command Prompt. To use the pear.bat with Command Prompt, follow the instruction at Send email from localhost/WAMP server using PEAR Mail and GMail #install-pear-packages. To use the WebFront, click on the Package Search button in the left pane in WebFront; select “pear.php.net” for the Channel dropdown listbox; search and install each packages (MIME_Type, Mail, Mail_Mime, Net_SMTP, Net_Socket) one-by-one; and after installing packages, read ahead from here to process to sending email.
  18. 4.36 avg. rating (79% score) - 11 votes
  1. Hi,
    following this tutorial, during installation phase I received following error:

    Class ‘PEAR’ not found in C:\wamp\www\go-pear.php on line 697

    and installation stops.

    guide me please.

    regards

    • It seems that the “include_path” setting of php.ini doesn’t include the path to the PEAR folder. Please open “C:\wamp\bin\apache\apacheX.Y.Z\php.ini”, search for “include_path” setting. Secondly, search for PEAR folder in WAMP’s folder; it is mostly at “C:\wamp\bin\php\phpX.Y.Z\PEAR”. Add this path with already defined value of “include_path” setting in php.ini. The setting’s line should be similar to this:
      include_path = ".;C:\wamp\bin\php\php5.2.6\PEAR"

  2. im getting this error during installation..

    Deprecated: Function ereg() is deprecated in C:\wamp\www\go-pear.php on line 1451

    any help

    • PEAR packages are very great idea but the problem with most of PEAR packages is – they are not updated since some years. The error you have mentioned is also because of this laziness. ereg() is POSIX function and now they are considered deprecated (more info: PHP: ereg – Manual). So, now the PEAR packages should be updated to replace the deprecated functions with newer preferred function. Currently, PCRE regular expression functions are in use. ereg‘s alternative function is preg_match().

      However, presently, the error you are seeing is just a warning, and it can be ignored. To ignore warnings of deprecated functions, you can set the error_reporting setting in php.ini file. Search for “error_reporting” in php.ini and add “ & ~E_DEPRECATED” at the end of this line.

  3. Hi Sir,
    Im getting below error

    Strict standards: Non-static method PEAR::setErrorHandling() should not be called statically in C:\wamp\www\go-pear.php on line 697.

    Help me please.

    Regards,
    Channabasappa.

  4. Hi sir,

    I apparently have this error when i run the localhost page

    Error: the template directory (C:\php\pear\data\PEAR_Frontend_Web\data\templates) is not a directory, or not readable. Make sure the ‘data_dir’ of your config file (C:\php\pear\data) points to the correct location !

    Could you help me thanks.

Leave a Comment