Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PHP Pear without user prompt

Is there a command line argument that allows you to install PHP Pear without user prompt? I'd like to automate the following execution:

wget http://pear.php.net/go-pear.phar
php go-pear.phar
pear config-set preferred_state beta
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install --alldeps phpunit/PHPUnit
rm go-pear.phar

php go-pear.phar prompts the user for install/configuration information.

like image 818
Jake McGraw Avatar asked Aug 23 '11 16:08

Jake McGraw


1 Answers

Turns out expect did the trick. Here is what I ended up with:

install-pear.sh

#!/usr/bin/expect
spawn wget -O /tmp/go-pear.phar http://pear.php.net/go-pear.phar
expect eof

spawn php /tmp/go-pear.phar

expect "1-11, 'all' or Enter to continue:"
send "\r"
expect eof

spawn rm /tmp/go-pear.phar

install-phpunit.sh

#!/bin/bash
./install-pear.sh
pear config-set preferred_state beta
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install --alldeps phpunit/PHPUnit

To run:

sudo apt-get install expect
chmod 744 ./install-pear.sh
chmod 744 ./install-phpunit.sh
sudo ./install-phpunit.sh
like image 150
Jake McGraw Avatar answered Sep 26 '22 12:09

Jake McGraw