So where we are currently working, we have a back catalogue of Symfony 1.0 applications, and are beginning to roll out a few Symfony 1.1 apps to production, as well as a few other things floating around on other versions. As helpful as the compatability plugin is, it can’t magically make any 1.0 app run under 1.1, and we made the decision that we just couldn’t afford the time to re-write… So what’s the best way of running multiple versions of Symfony apps together on the one environment?

The first thing we thought of was just using PEAR to install multiple version in different directoris, but unfortunately it cannot handle installing more than one version, so that’s out.

You could grab a Symfony sandbox for each application, and if you only had one or two 1.0 apps this is probabaly quite a valid option, but if you have a few more, your code-base would get very large, very quickly, and you miss out on the benefit of re-using components across your apps from one location.

So what did we actually do? In the end, we installed multiple versions of Symfony via SVN, allowing the environment to operate much as anyone who installed Symfony with PEAR would be familiar with, allowing each Symfony application to reference the global Symfony install and libraries etc.  The example below document how this was set up in Ubuntu (our favoured development VM), but shouldn’t be too different form other Unix environments.

Step 1 - Un-install Symfony via PEAR
If you have Symfony installed via PEAR, get rid of it, it will only confuse you with what we are about to do.

express@express-dev:~$ sudo pear uninstall symfony/symfony
uninstall ok: channel://pear.symfony-project.com/symfony-1.1.0

Step 2 - Setup a structure for Symfony
In our case, I still want to install symfony in /usr/share/php/symfony, so lets set that up:

express@express-dev:~$ cd /usr/share/php
express@express-dev:/usr/share/php$ sudo mkdir symfony

Step 3 - Checkout each Symfony version you need
Now lets use SVN checkout to grab each Symfony version we are after, lets put these in a different folder under the base Symfony directory. Note: If you are behind a proxy, change your SVN settings first to go through your proxy. To change your proxy settings:

express@express-dev:/usr/share/php/symfony$ sudo nano /etc/subversion/servers

Now lets checkout each symfony version:
express@express-dev:/usr/share/php$ cd symfony/
express@express-dev:/usr/share/php/symfony$ sudo svn co http://svn.symfony-project.com/branches/1.0 symfony10
...
express@express-dev:/usr/share/php/symfony$ sudo svn co http://svn.symfony-project.com/branches/1.1 symfony11
...
express@express-dev:/usr/share/php/symfony$ sudo svn co http://svn.symfony-project.com/branches/1.2 symfony12
...

We now have created three installations of Symfony.

Step 4 - Create symbolic links for each version
The next step is for us to create symlinks for each version of Symfony. Lets place these in the standard bin directory:

sudo ln -s /usr/share/php/symfony/symfony10/data/bin/symfony /usr/bin/symfony10
sudo ln -s /usr/share/php/symfony/symfony11/data/bin/symfony /usr/bin/symfony11
sudo ln -s /usr/share/php/symfony/symfony12/data/bin/symfony /usr/bin/symfony12

Now lets test the sym links:


express@express-dev:~$ symfony10 -V
symfony version 1.0.19-PRE
express@express-dev:~$ symfony11 -V
symfony version 1.1.5-DEV (/usr/share/php/symfony/symfony11/lib)
express@express-dev:~$ symfony12 -V
symfony version 1.2.0-DEV (/usr/share/php/symfony/symfony12/lib)

What next? - Creating a new project
So to create a new project, you will need to use the relevant Symfony command. For example, to create a Symfony 1.0 project:

sudo symfony10 init-project test1

or to create a Symfony 1.1 or Symfony 1.2 Project:


sudo symfony11 generate:project test11
sudo symfony12 generate:project test12

Once you create a new project, check in the project Config to ensure its picked up the right version. For Symfony 1.0:

express@express-dev:/usr/local/express/projects/$ sudo symfony10 init-project test10
express@express-dev:/usr/local/express/projects/$ cat config/config.php

// symfony directories
$sf_symfony_lib_dir  = '/usr/share/php/symfony/symfony10/lib';
$sf_symfony_data_dir = '/usr/share/php/symfony/symfony10/data';

for Symfony 1.1:
express@express-dev:/usr/local/express/projects/test$ cat config/ProjectConfiguration.class.php

require_once '/usr/share/php/symfony/symfony11/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
  }
}

and for Symfony 1.2, its the same, just make sure its including the right 1.2 files. Thats it! Hope this helps!