Using multiple PHP versions in Gentoo
Background
As Matti recently wrote about, Gentoo will start supporting multiple concurrent PHP installs through minor version slotting.
PHP allows for ABI breaks for every minor version release. This means that for every upgrade to a new minor version, e.g from 5.3 to 5.4, you have to recompile your PECL packages and other extensions such as suhosin, xdebug and eaccellerator. Many extensions, especially suhosin, xdebug and opcode caches, often need to be rewritten in order to work properly with the new ABIs.
In addition, PHP tend to ship with quite a lot of new functionality with minor versions. PHP 5.3 saw the coming of closures, namespaces and late static bindings. In addition, quite a lot of functionality got deprecated and a few functions changed behaviour.
Because of the change in behaviour and the ABI changes breaking extensions, many developers, me included, want to be able to experiment with the new functionality of a new minor version, while still developing using the previous, more stable minor version.
Gentoo currently support major version slotting, but as outlined above, this is not really sufficient. The implementation of the major version slotting is based around having one category for every slot, e.g dev-php4 and dev-php5, and copying packages into the categories that each package supports. This means that you would have both a package called dev-php4/phpunit and dev-php5/phpunit.
In addition there is a dev-php category for packages that work across all PHP versions. However, all PEAR packages, regardless of whether it works across all PHP versions or not, is placed in dev-php, breaking this scheme.
Choosing which slot to use is done through php-select found in the app-admin/php-toolkit package. It allows you to chose which php installation to use for CLI, mod_php (apache2) etc. Many of you are probably not aware of this since it has been a while since php4 support was dropped.
Enter minor version slotting
Because of the ABI breaks and the change of behaviour in between minor versions of PHP, Gentoo will soon support minor version slotting. This will be implemented concurrently with cleaning up PHP related eclasses and merging the PHP related package categories into one single category.
The implementation of minor version slotting is founded on an eselect module for PHP.
After the install of each new PHP slot, the eselect module will enable the slot for building PECL packages. This allows users to chose which PHP installations extensions should be built for. PHP ebuilds will automatically enable extension-building for newly installed slots. Compared to the current scheme of major version slotting, the one disadvantage of this approach is that you cannot build extensions with different USE flags for individual slots. All extensions have to be built with identical configurations. NOTE: An alternative to this is to build all extensions for all installed slots. This is actually what happens if you do not disable slots manually.
Building extensions for multiple slots
eselect php enable php5.3 enables extension-building for PHP 5.3, while eselect php disable php5.2 disables extension building for PHP 5.2.
This was changed to using USE_EXPAND instead. See: Building PHP extensions against multiple slots using PHP_TARGETS
Choosing which PHP installation to use
In order to use a new PHP installation for CLI or apache2 you will have to switch manually using, once again, eselect-php: eselect php set apache2
This might be seen as a bit of a configuration overhead, but with the current rate of PHP development, you shouldn’t have to run these commands more than once every other year.
when i try to emerge eselect-php it tries to fetch from
http://distfiles.gentoo.org/distfiles/eselect-php-0.4.bz2
http://olemarkus.org/~olemarkus/gentoo/eselect-php-0.4.bz2
and both fail with 404 error. Can You fix this?
I will fix it soon, I hope. Until then, the easies thing to do is to do something like this:
But there are only ebuilds and manifest there. Where do i get the sources?
See the directory I pointed you to. It is ./eselect-php not ./app-admin/eselect-php.
I.e the source for eselect-php is also in the php overlay repository.
Cheers!
sorry, been looking into /path/to/overlay/app-admin/eselect-php instead of /path/to/overlay/eselect-php. Works now, thank you.
thanks for eselect-php-0.4.bz2. works like a charm