I want to install PHP PEAR on Windows non-interactively.

If I just download http://pear.php.net/install-pear-nozlib.phar and run it like this:

php install-pear-nozlib.phar

It gets installed into C:\php.

But my PHP is installed into C:\PHP5 (and it is in the %PATH%).

So I want to somehow install PEAR into C:\PHP5, but can't find a way to do it.

What way of installing PEAR do you recommend in my situation?


I was able to achieve my goal by automating the interactive PEAR installer using the expect port for Windows.

Here is the install_pear.tcl script I created:

package require Expect

spawn php "go-pear.phar"

expect "system\|local" {
    exp_send "system\r\n"

expect "Enter to continue" {
    exp_send "\r\n"

expect "Would you like to alter php.ini" {
    #exp_send "y\r\n"


The commented-out lines might be required, depending on how you run the script.

The script needs to be run from the required target directory, in my case it's the PHP root directory, C:\PHP5:

cd C:\PHP5
tclsh install_pear.tcl

You may also want to look at the ActiveTCL unattended installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.