3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the LGPL. For more information, see
17 * <http://www.doctrine-project.org>.
21 * Install PHP extensions required for testing by Travis CI.
23 * @author Victor Berchet <victor@suumit.com>
26 $installer = new PhpExtensions();
28 if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) {
29 $installer->install('apc');
31 $installer->install('xcache');
34 $installer->install('memcache');
35 $installer->install('memcached');
39 protected $extensions;
40 protected $phpVersion;
43 public function __construct()
45 $this->phpVersion = phpversion();
46 $this->iniPath = php_ini_loaded_file();
47 $this->extensions = array(
49 'url' => 'http://pecl.php.net/get/memcache-2.2.6.tgz',
50 'php_version' => array(),
51 'cfg' => array('--enable-memcache'),
52 'ini' => array('extension=memcache.so'),
55 'url' => 'http://pecl.php.net/get/memcached-1.0.2.tgz',
56 'php_version' => array(
57 // memcached 1.0.2 does not build on PHP 5.4
61 'ini' => array('extension=memcached.so'),
64 'url' => 'http://pecl.php.net/get/APC-3.1.9.tgz',
65 'php_version' => array(
66 // apc 3.1.9 causes a segfault on PHP 5.4
77 'url' => 'http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz',
78 'php_version' => array(
79 // xcache does not build with Travis CI (as of 2012-01-09)
82 'cfg' => array('--enable-xcache'),
84 'extension=xcache.so',
85 'xcache.cacher=false',
86 'xcache.admin.enable_auth=0',
93 public function install($name)
95 if (array_key_exists($name, $this->extensions)) {
96 $extension = $this->extensions[$name];
99 echo "== extension: $name ==\n";
101 foreach ($extension['php_version'] as $version) {
102 if (!version_compare($this->phpVersion, $version[1], $version[0])) {
104 "=> not installed, requires a PHP version %s %s (%s installed)\n",
114 $this->system(sprintf("wget %s > /dev/null 2>&1", $extension['url']));
115 $file = basename($extension['url']);
116 $this->system(sprintf("tar -xzf %s > /dev/null 2>&1", $file));
117 $folder = basename($file, ".tgz");
118 $folder = basename($folder, ".tar.gz");
119 $this->system(sprintf(
120 'sh -c "cd %s && phpize && ./configure %s && make && sudo make install" > /dev/null 2>&1',
122 implode(' ', $extension['cfg'])
124 foreach ($extension['ini'] as $ini) {
125 $this->system(sprintf("echo %s >> %s", $ini, $this->iniPath));
127 printf("=> installed (%s)\n", $folder);
131 private function system($cmd)
136 printf("=> Command '%s' failed !", $cmd);