Wondering what symfony 1.1 will look like? Well, I couldn’t hold my curiosity neither, so I upgraded one of my websites to symfony 1.1, and I describe here how to setup a box to run both versions. The upgrade process being definitive for a given project, make backups or svn commit before upgrading.
WARNING: Symfony 1.1 is a development version, and should not be used for production. Use it at your own risks.
First of all, i did not want the upgrade to be definitive, I needed a simple way to go back to older version. But SVN would handle this, no problem. On an other side, I needed to keep the two symfony version running on the same box, as other sites are running on it.
My approach to it was to checkout the symfony trunk/lib and trunk/data in /usr/share/pear/symfony1.1 and /usr/share/pear/data/symfony1.1 respectively. This way, i can switch any project I want to symfony 1.1 by changing the config/config.php to use the development version paths.
cd /usr/share/pear/ svn co http://svn.symfony-project.com/trunk/lib symfony1.1 svn co http://svn.symfony-project.com/trunk/data data/symfony1.1
That should retrieve a local copy of the latest development version on your computer.
Upgrading a 1.0 project
To upgrade a project, your first need is to tell the symfony batch script where to find its libraries. Hopefully, symfony’s structure permits to set per-project library paths by changing config/config.php. Edit this file and replace the file content by the new 1.1 paths
// symfony directories
$sf_symfony_lib_dir = '/usr/share/pear/symfony1.1';
$sf_symfony_data_dir = '/usr/share/pear/data/symfony1.1';You can test your changes were effective by typing symfony in your project directory. You should now see the new namespaced pake tasks that come with symfony 1.1. As in every version, an upgrade pake task that automates the changes you have to make to your project to make it work with the new version is given, and you can do:
symfony project:upgrade1.1 symfony cache:clear
(Note that old symfony cc alias still exists for the cache:clear task)
At this point, I tryed to see if my project would be working, but a nice uncaught LogicException was showing up in development environment, and I had to manually change %project_dir%/apps/*/config/config.php (look at spl_autoload_register line…).
After a little investigation, i found that running the task twice would autocorrect it, and that it was a little problem in lib/task/project/upgrade1.1/sfAutoloadingUpgrade.class.php, so i sent a ticket on Symfony’s TRAC.
Now you should have your project up and running.
Generating a new 1.1 project
That’s easier than upgrading, but the only (little) difficulty comes from the fact that ’symfony’ script will look for 1.0 libraries. For this, you’ll create a copy of /usr/bin/symfony to /usr/bin/symfony1.1 (you’ll need to be root for this), and change its content to:
#!/usr/bin/env php
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// project exists?
if (file_exists('config/config.php'))
{
include('config/config.php');
}
if (!isset($sf_symfony_lib_dir))
{
if (is_readable(dirname(__FILE__).'/../../lib/VERSION'))
{
// SVN
$sf_symfony_lib_dir = realpath(dirname(__FILE__).'/../../lib');
$sf_symfony_data_dir = realpath(dirname(__FILE__).'/..');
}
else
{
// PEAR
$sf_symfony_lib_dir = '/usr/share/pear/symfony1.1';
$sf_symfony_data_dir = '/usr/share/pear/data/symfony1.1';
if (!is_dir($sf_symfony_lib_dir))
{
throw new Exception('Unable to find symfony libraries');
}
}
}
include($sf_symfony_data_dir.'/bin/symfony.php');
You can now run
symfony1.1 generate:project
in a new directory to have a 1.1 project skeleton built there.
Have fun with it, I’ll post articles about the new form/validation system and upgrading your doctrine schemas to the rewritten sfDoctrinePlugin (that works both in 1.0 and 1.1) soon.