Upgrade from Symfony 0.6 to 1.0beta-1
Saturday, December 9th, 2006If you are like me, you have a few sites that are up and running with version 0.6 and they seem to be happy in their stable v0.6 state. You used the PEAR install because really you just wanted an easy way to get started. You built a few sites with it, and now you’d like to jump into the latest version and see what it has to offer.
How do I keep my existing symfony sites happy, but still install the latest SVN version to use with new projects?
First, let’s decide on this: We are going to keep the old PEAR installation just the way it is. The goal is to not have to go back into any existing sites and allow them to keep on working just like they always have been. The problem for me is that I already was playing around with the latest beta by way of “pear upgrade symfony/symfony-beta”. I’ll need to undo this and get my old version back:
#sudo pear upgrade -f symfony/symfony-0.6.3
Notcie the “-f” flag forces the installation of the older version.
Know, Understand, and Love the old PEAR installation.
Just so that I don’t go into this completely blind, I’m going to take a minute and try to understand where the symfony code actually goes when I do a PEAR install. If you run the command “pear config-show”, you should see a list of settings for your PEAR installation. For me, my pear directory is “/usr/local/php5/lib/php”. The old symfony files are all in there. After a bit of investigation I start to recognize the directory structure from the symfony trunk:
/usr/local/php5/lib/php/symfony (”/lib” folder in symfony trunk)
/usr/local/php5/lib/php/data/symfony (”/data” folder in trunk)
/usr/local/php5/bin/symfony (”/bin/symfony” shell script in trunk)
Phew, at least that mystery is solved. Now that I have undone the previous upgrade and have my old version of symfony running the way it was, I need to get my hands on the latest and greatest version from SVN. I don’t want to use the sandbox download because I can’t upgrade it with latest revisions in the repository. So, instead I’ll download a version of symfony from the SVN repository. While doing this I’ll have to be careful to leave my PEAR installation alone.
Download latest version of Symfony from SVN
1. Create a location to download the latest code from the svn repository.
I’m just going to put them in “/usr/local/php5/lib/php/mysymfony”, although you could put them anywhere.
#sudo mkdir /usr/local/php5/lib/php/mysymfony
#cd /usr/local/php5/lib/php/mysymfony
#svn co http://svn.symfony-project.com/trunk/ .
It might take a few minutes to download all of the code into your new folder. Remember, because this is under version control, anytime you want to grab the latest changes to the trunk you can run:
#svn update
from within the “mysymfony” directory and it will update automatically.
2. Create the appropriate link to the new “symfony” shell file so you can run it from the command line.
There are a few ways you can do this, but I’m going to create a symlink to the new symfony file and place it right next to the old symfony shell script:
#sudo ln -s /usr/local/php5/lib/php/mysymfony/data/bin/symfony /usr/local/php5/bin/symfony1.0
What this is basically saying is: “Create a link -symbolically to […]data/bin/symfony and put it in […]/php5/bin/symfony1.0
Now I should be able to call symfony1.0 from the command line and be using the new version.
# symfony1.0 -V
> symfony version 1.0.0-beta2
Let’s try to make a new project using our latest version of symfony:
#mkdir ~/Sites/sf_beta_test
#cd ~/Sites/sf_beta_test
#symfony1.0 init-project sf_beta_test
Success!! I can check and see if it’s going to be using the new symfony libraries by checking in /sf_beta_test/config/config.php. I see it is using the latest lib and data directories:
// symfony directories
$sf_symfony_lib_dir = ‘/usr/local/php5/lib/php/mysymfony/lib’;
$sf_symfony_data_dir = ‘/usr/local/php5/lib/php/mysymfony/data’;
To get my “/sf” directory working in my new project, I have to make sure to set up my host so that knows where to find them. I do this within my httpd.conf file in my Apache/conf directory. (See http://www.symfony-project.com/askeet/1)
<VirtualHost 127.0.0.1>
DocumentRoot [path-to-symfony-project]/web
ServerName sf_beta_test
Alias /sf /usr/local/php5/lib/php/mysymfony/data/web/sf
<Directory [path-to-symfony-project]/web>
Options All
AllowOverride All
</Directory>
</VirtualHost>
Alternatively, I could create a symlink within my app’s web directory called “sf” and point it to the right directory:
#cd ~/Sites/sf_beta_test/web
#ln -s /usr/local/php5/lib/php/data/symfony/web/sf sf
I will probably have to do that once I deploy my project to my shared host on the internet, because I won’t have access to the httpd.conf there! (Unless of course I use the “freeze” command!! More on that elsewhere.)
In summary, I now have two version of Symfony installed on my development machine.
1. The PEAR installation is of the latest stable version, symfony-0.6.3. These files are all in:
“[PEAR directory]/symfony” and “[PEAR directory]/data/symfony”. The binary is in “/usr/local/php5/bin/symfony”
2. The SVN installation is the latest version of the code. It is checked out into “/usr/local/php5/lib/php/mysymfony”.
I have a symlink in /usr/local/php5/bin/ named symfony1.0 that points to the new symfony shell script, originally found in “/usr/local/php5/lib/php/mysymfony/data/bin/symfony”.