Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

phpfarm - 複数のバージョンを同一マシンに簡単にインストールする

取り急ぎ、商会紹介だけ。
過去にid:hnwさんが全バージョンのバイナリ持ってますという話をされてましたが、同一マシンに複数のバージョンのPHPを簡単にインストールするphpfarmコマンドがsvn.php.netに登録されているようです。

  1. Test on different machines with another PHP version on each
  2. Test on different PHP versions on one machine

Solution number 1 requires either much hardware or at least quite some setup time for virtual machines. Besides that, running tests regularly on many different machines needs automated deployment tools - you won't ssh into the 15th machine manually, let alone setting up database servers and other software that might be required.

There is no single Linux distribution I know of that supports installing multiple versions of PHP beside each other - making solution number 2 similar daunting to setup and running as #1. The benefits above #1 are obvious: All software on one machine means easier deployment because the software to test needs to be setup only once. Software dependencies need to be installed only once. Executing the tests is easier if all versions of PHP are on this single machine, which means that the cross-version tests can be automated really easily.

A tool to solve all problems with the multiple-php-versions-on-one-machine solution is phpfarm.

ソースは、次の場所。

たとえば、PHP5.3.2をインストールする場合は次のような手順になるようです。

$ svn co http://svn.php.net/repository/pear/ci/phpfarm/trunk/ phpfarm
$ cd phpfarm/src
$ ./compile.sh 5.3.2
... fetching sources from php.net
... configuring
... compiling
... installing
... fetching and setting up pyrus
$ php-5.3.2 --version
PHP 5.3.2 (cli) (built: Mar 10 2010 18:08:27) (DEBUG)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
$ pyrus-5.3.2 --version
Pyrus version 2.0.0a1 SHA-1: 2FDFB5E00A6D707437DBC047AAF9D115C6484D90
Using PEAR installation found at /home/cweiske/Dev/cvs/pear/phpfarm/inst/php-5.3.2/pear
php pyrus.phar version 2.0.0a1.
$ 

各コマンドは基本的にshスクリプトで、ざっと眺めた感じ、

のようです。

shスクリプトを好きなように変更すれば、テスト環境だけじゃなく、もっとマニア(?)な環境も楽にできるかも知れません。