Installing multiple versions can be accomplished by using the --installroot
option to the pear
command:
1 2 | [code language="bash"]sudo pear config-set auto_discover 1 sudo pear install --installroot /some/path/phpunit34 pear.phpunit.de/PHPUnit-3.4.15[/code] |
This will install PHPUnit-3.4.15 to /some/path/phpunit34
.
You will need to make a small change to one of the installed files to fix the include_path
. If you installed the package to /some/path/phpunit34
the file you want to change is /some/path/phpunit34/usr/bin/phpunit
. Before the first require_once
statement in that file, enter the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [code language="php"] // Ubuntu / Debian set_include_path(implode(PATH_SEPARATOR, array( dirname(__FILE__) . '/../share/php', get_include_path() ))); // CentOS set_include_path(implode(PATH_SEPARATOR, array( dirname(__FILE__) . '/../share/pear', get_include_path() ))); [/code] |
The path you need to prepend to PHP’s include_path
is different from distro to distro. To see the path your system uses run the following command:
1 | [code language="bash"]pear config-show|grep php_dir[/code] |
or simply look around in the directory where you installed the specific version of PHPUnit.
The last part of the puzzle is to place a symlink to the file you just edited in /usr/bin. This can be done by running the following command:
1 | [code language="bash"]sudo ln -s /some/path/phpunit34/usr/bin/phpunit /usr/bin/phpunit34[/code] |
To verify that everything works you can run these commands:
1 2 3 4 5 6 | [code language="bash"]christere@spongebob:~$ phpunit --version PHPUnit 3.6.4 by Sebastian Bergmann. christere@spongebob:~$ phpunit34 --version PHPUnit 3.4.15 by Sebastian Bergmann. [/code] |
Feel free to leave a comment if you see any possible problems with this solution.