PEAR Installation Tutorial

Installing PHP PEAR packages is pretty simple, but you need to make sure you have PHP and Apache correctly installed before you get started.

Installing PEAR

If you’ve correctly set your path in the windows system properties as described in my PHP installation tutorial, then installing PEAR will be extremely simple.

Step 1)Open up the run window by holding the windows key and pressing R. Type in “cmd” and press enter to bring up the command prompt.
Bring up the run window

Alternatively, you can open the command prompt in the accessories folder of the start menu.
Bring up the command prompt

Step 2)Once the command prompt is open, change the current directory to the php directory. If you followed my php installation tutorial, your php folder is located at C:\webserver\php. So to change to the directory in the command prompt, you would type:

cd C:\webserver\php

(cd stands for Change Directory in the command prompt. )
Once you press enter, you should see that the directory has changed in my case from C:\Users\Joseph to C:\webserver\php.

Change the directory

Step 3)Now that you are in the php directory, type in

go-pear.bat

This loads the pear installation batch file that came with PHP. You will be prompted with the question:
“Are you installing a system-wide PEAR or a local copy?” You can type in either system or local as your response. I chose system. Press Enter.

Enter go-pear.bat

Step 4)A wall of text will hit your screen. PEAR is basically allowing you to change installation directories if you wish. If you want to keep everything in the default installation directories (which I recommend), then press Enter. PEAR will begin to install, and you will see a lot of text, until you come across this message:

Pear Warning

Type in Y and press enter. When prompted, press enter again. You will see

The 'pear' command is now at your service at c:\webserver\php\pear.bat

Pear is now ready

Step 5)You are also told a registry file named PEAR_ENV.reg has been created in the php directory.

Pear Registry Configuration

Open up your php directory (C:\webserver\php) and look for the PEAR_ENV.reg file. When you locate it, double click it and grant it permission.

Step 6)Installing PEAR Packages:
Now that you have PEAR installed, you can start installing some packages. A list of the most useful and most downloaded PEAR Packages can be found at the PEAR Projects official website. For this example, let’s install HTML_Template_IT, which is a way to use integrated templates with PHP.

Step 7)If you have closed the command prompt, open it up again and make sure you are in the C:\webserver\php directory. (Refer to step 2 if you can’t remember how to switch directories)

Step 8)Now simply type in

pear install HTML_Template_IT

into the command prompt, press enter, and it will install!

Installing with Pear

Step 9)If you want to uninstall a PEAR Package, you follow the same procedure but type “uninstall” instead of install. So to uninstall HTML_Template_IT, you would go to the command prompt and type

pear uninstall HTML_Template_IT

Uninstalling with Pear

That concludes the installation of Pear.

Warning: require_once(Structures/Graph/Node.php)

If you’ve come across this error while installing PEAR, Max has left us a potential solution in the comments. Let us know if it works!


Related Posts:

About the Author:

Joseph is the lead developer of Vert Studios, a web design company located in Tyler, Tx. Follow him on Twitter! @Joe_Query.

  1. Roman

    Joseph, I installed HPH and Apache ands everything workede. i setup the path to PHP folder in system propertied. when i tried to install PEAR i received message below:
    C:\webserver\php>go-pear.bat
    phar “C:\webserver\php\PEAR\go-pear.phar” does not have a signaturePHP Warning:
    require_once(phar://go-pear.phar/index.php): failed to open stream: phar error:
    invalid url or non-existent phar “phar://go-pear.phar/index.php” in C:\webserve
    r\php\PEAR\go-pear.phar on line 1236

    Warning: require_once(phar://go-pear.phar/index.php): failed to open stream: pha
    r error: invalid url or non-existent phar “phar://go-pear.phar/index.php” in C:\
    webserver\php\PEAR\go-pear.phar on line 1236
    Press any key to continue . . .
    Any sugestions?

  2. Roman

    JOseph, i found the fix for previouse error. when i try to install HTML_Template_it, i received another error: Warning: require_once(Structures/Graph.php): failed to open stream: No such file
    or directory in PEAR\Downloader.php on line 1217
    PHP Warning: require_once(Structures/Graph.php): failed to open stream: No such
    file or directory in C:\webserver\php\PEAR\PEAR\Downloader.php on line 1217

    Warning: require_once(Structures/Graph.php): failed to open stream: No such file
    or directory in C:\webserver\php\PEAR\PEAR\Downloader.php on line 1217
    PHP Fatal error: require_once(): Failed opening required ‘Structures/Graph.php’
    (include_path=’C:\webserver\php\pear’) in C:\webserver\php\PEAR\PEAR\Downloader
    .php on line 1217

    Fatal error: require_once(): Failed opening required ‘Structures/Graph.php’ (inc
    lude_path=’C:\webserver\php\pear’) in C:\webserver\php\PEAR\PEAR\Downloader.php
    on line 1217

    any sugestions?

  3. Roman

    disregard my second error, i found how to fix it

    • dany

      Hi , how did you fix second error . I have that here , please tell me >

    • Say Roman,

      Care to share that fix you discovered for the following? I would really appreciate it!

      >>>>>>>>

      HTML_Template_it, i received another error: Warning: require_once(Structures/Graph.php): failed to open stream: No such file
      or directory in PEAR\Downloader.php on line 1217
      PHP Warning: require_once(Structures/Graph.php): failed to open stream: No such
      file or directory in C:\webserver\php\PEAR\PEAR\Downloader.php on line 1217

      Warning: require_once(Structures/Graph.php): failed to open stream: No such file
      or directory in C:\webserver\php\PEAR\PEAR\Downloader.php on line 1217
      PHP Fatal error: require_once(): Failed opening required ‘Structures/Graph.php’
      (include_path=’C:\webserver\php\pear’) in C:\webserver\php\PEAR\PEAR\Downloader
      .php on line 1217

      Fatal error: require_once(): Failed opening required ‘Structures/Graph.php’ (inc
      lude_path=’C:\webserver\php\pear’) in C:\webserver\php\PEAR\PEAR\Downloader.php
      on line 1217

      <<<<<<<<<<

  4. Roman

    Joseph, do you have instructions how to install phpMyadmin?

  5. Roman

    Joseph

    Have you had the chance to upload phpmyadmin installation? I tried the once i found on the net and non of the worked. I can not fined what i am doing wrong. Hopefully your instruction will help me.

    • Roman,

      Sorry, I got busy with some projects. I had to reinstall PhpMyAdmin on my computer, and I made sure to take screenshots so I could put a post up for you soon.

  6. Roman

    Joseph, i went ahead and install phpmyadmin. When i tried to open http://localhost/phpmyadmin i got an error: mysql can not be load, check configurations”. i checked configurations of phpmyadmin and they were OK. The problem i found is with configurations in php.ini. In that file you instructed to change extension_dir = “ext” with “C:\webserver\php\ext”. I removed the quots for the path to look like C:\webserver\php\ext and then was able to open http://localhost/phpmyadmin.
    This was the only problem i had. Thank you for all your work to create and upload instruction for PHP, MySQL and REAR. They were vary halpfull.

    • Strange that you had that issue, but I’m glad you have it worked out! I have the quotes in my extension_dir. It might have been that your mysql extensions were commented out in the php.ini file (which they are by default). In either case, I’m glad you got it working!

  7. G Molvi

    Thankx a lot champ. you did a great effort by explaining those screen shots , saved a lot of my time and effort . Have a lovey life. Cheers

  8. Good explanetion, Thanks

  9. what if we have no access to command line but only ftp access?

  10. alex

    thank you for this article :)

Add to the conversation: