7

perlbrew is a tool to manage multiple installations of Perl on your system, making it easy to, say, quickly run a suite of test scripts against many different versions of Perl.

Is there anything like that for PHP? For now when I want to change the version of PHP that my system uses, I'll go into the build directory for my desired version and run make install.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
mob
  • 117,087
  • 18
  • 149
  • 283
  • Why would you want an old PHP version? Software that is not compatible with a recent PHP version is most likely outdated and should not be used. – ThiefMaster Jun 08 '12 at 18:19
  • The idea is to test libraries and extensions compatible with both old and new versions of PHP, including release candidates and unstable dev versions. – mob Jun 08 '12 at 18:33
  • Ah, for testing with new versions it makes sense. Not sure about old ones. People need reasons to use recent PHP versions and when using shared hosting they need reasons to bug/switch ISPs for that reason. – ThiefMaster Jun 08 '12 at 19:11
  • 2
    @ThiefMaster There are a lot of situation for this ! For example in case you have to work for a client that uses PHP 5.2 etc ... I still have good paying clients with PHP 4 ;) – Sliq Jun 12 '12 at 11:40

6 Answers6

4

Here's one: http://www.navicopa.com - it allows you to switch between different versions of php in one click (just install them into different directories)

And here's a free one: https://github.com/c9s/phpbrew

Also - you might like this solution as an alternative, if you don't want to use side software: https://stackoverflow.com/a/5299385/1337343

Also missed that you use linux environment, so you would really like this: https://github.com/tobiasgies/php-switch

Install all php versions you need and switch between them using this tiny bash script.

Community
  • 1
  • 1
Ruslan Osipov
  • 5,655
  • 4
  • 29
  • 44
1

Maybe phpfarm could help you...

Miroslav Popovic
  • 12,100
  • 2
  • 35
  • 47
  • The version of `cweiske` doesn't seem to be maintained anymore. I personally am using the maintained version of `fpoirotte` from https://github.com/fpoirotte/phpfarm. – Shi May 31 '15 at 03:12
1

When you run ./configure, add --prefix=/usr/local/php-{version} (replacing {version} with the php version). Then to run a script with a certain version:

/usr/local/php-{version}/bin/php script.php

To run under a CGI environment

Make a symlink from /usr/local/bin/php-cgi to /usr/local/php-{version}/bin/php-cgi and then remake the symlink and restart the server when you want to switch php versions.

Cameron Martin
  • 5,952
  • 2
  • 40
  • 53
  • Isn't there much more to a php installation than this? `libphp5.so`? `/usr/include/php` or `/usr/local/include/php`? – mob Jun 12 '12 at 21:42
  • If you set the prefix, everything will be installed in that directory. So if you compile with shared libraries, they'll be under `/usr/local/php-{version}/lib/` – Cameron Martin Jun 13 '12 at 16:46
0

Maybe light offtopic, but for local development under windows some WAMP stacks provide excellent one-click switching of php versions. i had positive experiences with:

Sliq
  • 15,937
  • 27
  • 110
  • 143
0

Not sure whether this is all clear for you, but let me know if it's not :)

cli

For simple cli testing you can just install each version into their own folders, e.g. /usr/local/php-5.4/bin, /usr/local/php-5.3.10/bin, etc.

fastcgi

For some time you can run PHP in FastCGI mode. You can let a few versions run simultaneously and bind them to different ports, e.g. :9000, :9001, :9002, etc.

The next step is to set up multiple name based virtual hosts in either Apache, Nginx, Lighttpd or Node.js. Each virtual host binds to another FastCGI process and therefore uses a different version of PHP.

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
0

Maybe this is overkill for what you need, but if you don't mind using virtual machines Vagrant may be helpful.

Peter
  • 280
  • 2
  • 9