How do I use Propel 1.3 in symfony 1.1?

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.

  1. 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/sfPropelPlugin
  2. Propel 1.3 uses a new connection format and so you must update databases.yml accordingly. Change config/databases.yml to 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: PropelPDO
    

    To upgrade your DSN, see the PDO manual.

  3. We must update propel.ini to match the same configuration. Look for the 3 lines at the beginning of config/propel.ini and delete them:

    
    propel.database            = mysql
    propel.database.createUrl  = mysql://root@localhost/
    propel.database.url        = mysql://root@localhost/myproject
    

    In 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   = utf8
    

    Be sure that propel.databse.url matches the DSN in step 2.

  4. Clear symfony's internal cache:

    $ symfony cache:clear
  5. Propel 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.

Comments

I have written a script, which exports the latest branches of symfony 1.0.X, Propel 1.3, phing 2.3 cheole 1.1. The script applies some patches and merges these components all together. Doing this for almost 4 or 5 month now.

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.
After symfony cache:clear I tried symfony propel:build-model, which results in the fatal error below.

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!
Does this mean that Propel 1.2 is bundled with symfony 1.1 by default? Or is it just a choice of which plugin to install and nothing is included by default?
@Jordi: Try clearing the files /tmp/sf_autoload_*. If that doesn't work, email me at carl [dot] vondrick [at] symfony-project [dot] com and we can debug.

@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.
@Carl Vondrick: You have an e-mail from snowkrash [AT] xs4all [DOT] nl, hopefully not in your spambox ;-)
The error with MSG_VERBOSE is related to the "autoloader" not finding Phing in CLI mode.

Manually installing Phing 2.3 via PEAR clears the error.

see http://phing.info/trac/wiki/Users/Download
Yep, installing Phing 2.3 makes it all work. But now, my project is dependant of Phing through PEAR, while it should load the embedded Phing (which is inside the plugin). Or am I missing something?
Does not work if you want to store your session data in a database table, for example by using sfMySQLSessionStorage.class.php
Any way to install it on Windows 2K? Or VIA PEAR?

Slds
hi,
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)

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.