RVM equivalent for PHP?

PhpRubyRvmHomebrewRbenv

Php Problem Overview


I can't seem to find a way to switch versions of PHP quickly. Is there something equivalent to ruby version manager for php? I need to switch between 5.3 and 5.2 on OS X.

Php Solutions


Solution 1 - Php

For PHP alternatives to RVM and rbenv, you have phpbrew, phpenv and php-version. Please be aware that I am the author of php-version so of course I prefer it as I wrote it to scratch my own itch (I wanted something minimal with command completion); however, phpenv is quite good as well. You would do well to use either.

On OS X, you can install a PHP version manager using Homebrew.

First, add the PHP formulae for homebrew:

% brew tap homebrew/homebrew-php

Then, using the formulae installed from homebrew-php you can install either with:

% brew install php-version

or

% brew install phpenv

The php-version README.md lists a few more alternatives so you might want to have a look.

BTW, I would consider php-version to be more aligned with chruby in that it tries to do one thing well.

Solution 2 - Php

I think phpfarm is most close php alternative of rvm, it also installing pyrus which is like ruby gems for php world.

Solution 3 - Php

If you are not use php-cgi and Install different versions of PHP to different locations

  1. Find different version libphp5.so,and copy into the different location

  2. If use php5.3.11 or php5.4.11

    ln -s php5.3.11 php  || ln -s php5.4.11
    
  3. Depoly your apache httpd.conf

    LoadModule php5_module        YOUR_PHP_PATH/php/libphp5.so
    
  4. restart apache

    sudo apachectl restart
    

Solution 4 - Php

Have a look at phpenv (with php-build). There's even a homebrew recipe if you brew tap josegonzalez/php. It's actually a PHP version of rbenv not rvm but I think it's going to be the simpler to set up than phpfarm.

Solution 5 - Php

if you're running apache I can suggest the way I solved this. Install different versions of PHP to different locations and prepare few apache php-x.y.z.conf files like

ScriptAlias /php/ "path/to/php-5.2.10/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php-cgi"
<Directory "/php/">
	Order allow,deny
	Allow from all
</Directory>

,

ScriptAlias /php/ "path/to/php-5.3.0/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php-cgi"
<Directory "/php/">
	Order allow,deny
	Allow from all
</Directory>

and so on, so you can quickly change the name of included .conf file and restart server. Or, like I did, make several virtual hosts having the same document root, but with different versions of PHP included:

<VirtualHost *:80>
	DocumentRoot "C:/www/localhost"
	ServerName local.php-5.2.10

	Include conf/php-5.2.10.conf

	<Directory "C:/www/localhost">
		Allow from All
	</Directory>
</VirtualHost>

Solution 6 - Php

There is a great program for doing this, phpbrew. I actively use it and I can highly recommend it.

https://github.com/phpbrew/phpbrew/wiki/Cookbook

Solution 7 - Php

Here is my solution (pvers). A one-file script written completely in bash. If you are looking for a lite and easy to install php version manager with minimum dependencies - give it a try;)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjohmasView Question on Stackoverflow
Solution 1 - PhpWil Moore IIIView Answer on Stackoverflow
Solution 2 - PhpwikView Answer on Stackoverflow
Solution 3 - PhpcloudsbenView Answer on Stackoverflow
Solution 4 - PhpGeorgeView Answer on Stackoverflow
Solution 5 - PhpSlavaView Answer on Stackoverflow
Solution 6 - PhpLloyd MooreView Answer on Stackoverflow
Solution 7 - PhpzinovyevView Answer on Stackoverflow