Archives
Master Symfony2 fundamentals
Symfony hosting done right
Discover the SensioLabs Support
Blog
How do I use Propel 1.3 in symfony 1.1?
by
Carl Vondrick
– May 30, 2008
– 10 comments
Starting with symfony 1.1, it is now possible to easily use Propel 1.3 in your project to take advantage of its speed improvements, nested set implementation, object instance pooling, among others. Most importantly, Propel 1.3 uses PDO instead of Creole as the DBAL, offering a significant performance boost.
Thanks to Dustin Whittle, installing Propel 1.3 only takes a few minutes. All you must do is install a plugin and modify two configuration files. Read on to learn how.
Install the Propel 1.3 plugin from the symfony repository:
$ cd /path/to/project/root/ $ svn co http://svn.symfony-project.com/plugins/sfPropelPlugin/branches/1.3/ plugins/sfPropelPluginPropel 1.3 uses a new connection format and so you must update
databases.ymlaccordingly. Changeconfig/databases.ymlto match the following, making your own necessary changes.dev: propel: param: classname: DebugPDO all: propel: class: sfPropelDatabase param: dsn: mysql:dbname=mydb;host=localhost username: username password: password encoding: utf8 persistent: true pooling: false classname: PropelPDOTo upgrade your DSN, see the PDO manual.
We must update
propel.inito match the same configuration. Look for the 3 lines at the beginning ofconfig/propel.iniand delete them:propel.database = mysql propel.database.createUrl = mysql://root@localhost/ propel.database.url = mysql://root@localhost/myprojectIn their place, insert the following:
propel.database = mysql propel.database.driver = mysql propel.database.createUrl = mysql://localhost/ propel.database.url = mysql:dbname=mydb;host=localhost propel.database.user = username propel.database.password = password propel.database.encoding = utf8Be sure that
propel.databse.urlmatches the DSN in step 2.Clear symfony's internal cache:
$ symfony cache:clearPropel 1.3 has an improved object model, so we must rebuild the models:
$ symfony propel:build-model
If this is a new project, congratulations you have just setup Propel 1.3! The schema.yml syntax is exactly the same as Propel 1.2. The new API is not radically different; in fact, for the most part, the API is exactly the same.
If you are upgrading a project, you might still have a little bit of work ahead of you, but you should find that most of your project will work. If you use transactions or Creole directly in your code, you will have to manually upgrade to PDO. The Propel project has a helpful upgrade guide that guides you through the upgrade process. Even if this is a new project, you might find it helpful to glance over it to learn about all the new features.
symfony 1.1 decouples its core systems, so it couldn't be easier to use any ORM layer you want. If Propel doesn't cut it for you, try sfDoctrinePlugin, which is a alternative to Propel and matches the performance of Propel 1.3. Thanks to symfony 1.1, developers can enjoy Propel 1.3 for improved performance or Propel 1.2 if they require rock solid stability.





is a trademark of Fabien Potencier. All rights reserved.
Add a Comment
Comments
I am happy to hear that symfony 1.1 has Propel installed as a plugin and not build in the way it is with symfony 1.0.X.
Fatal error: Undefined class constant 'MSG_VERBOSE' in D:\Websites\projects\hetlijstjevan\plugins\sfPropelPlugin\lib\vendor\propel-generator\classes\propel\phing\AbstractPropelDataModelTask.php on line 433
Why is this? After this is solved, I hope this boosts my app. It sounds promising!
@Akinas: Propel 1.2 is bundled with symfony 1.1 and is included by default. If you want to use Propel 1.3, you should follow these instructions to install Dustin's plugin in your project.
Manually installing Phing 2.3 via PEAR clears the error.
see http://phing.info/trac/wiki/Users/Download
Slds
try to follow your instruction from the cookbooks about using propel 1.3 with symfony 1.1, but i've stuck into this error while trying to running step 4 (clearing cache) :
Fatal error: Cannot redeclare class sfPropelBaseTask in D:\xampp\htdocs\test.1.1
\plugins\sfPropel13Plugin\lib\task\sfPropelBaseTask.class.php on line 265
any solutions ? i really want to use this for my next projects (as i'm still in sf 1.0.X with sfPropel13Plugin by now)