Using Doctrine 1.1 with Symfony 1.2
I recently started a new project using the Symfony PHP Framework. I’ve used Symfony before and love it. In the past I’ve used Propel, but as Symfony now fully supports Doctrine and Doctrine looks very promising, I decided to give it a shot for my latest project.
Symfony 1.2 currently uses Doctrine 1.0. Doctrine 1.1 was released in March. Symfony 1.3 will support Doctrine 1.1, but won’t be released until November.
Since I’m starting a new project, I wanted to try to use the latest version of Doctrine. I’ll be honest, I don’t have a great reason for doing this other then the pain I went through migrating an old project (with lots of custom model stuff) from Propel 1.2 to Propel 1.3. I understand this is an apples to oranges comparison, however its the only motivation I’ve got. Feel free to stop reading now.
Overall the Symfony developers have made it extremely easy to use Doctrine 1.1 with Symfony 1.2. However, given this is an unsupported configuration, they don’t back-port any patches related to Doctrine 1.1 from the Symfony 1.3 branch to sf 1.2. In this post I will try to catalog the changes and provide a back-port patch you can use to integrate Doctrine 1.1 into your sf 1.2 projects.
Related Postings
Here are some pages/tickets/changesets related to Doctrine 1.1 with Symfony. If I’m missing something, please leave me a comment below and I’ll update this ASAP!
| Symfony Blog | Call the expert: Using a custom version of Doctrine |
| Ticket 5667 | In generated forms, Doctrine 1.1 does not save model after linking relations. |
| Ticket 5741 | CLI doesn’t use the right installation of Doctrine |
| Ticket 6285 | Form generator, saving linked objects problem (SF 1.2 + Doctrine 1.1) |
| Changeset 16508 | fix for admin gen and Doctrine 1.1 link()/unlink() methods (fixes #5667, #6285) |
| Ticket 6373 | sfDoctrineGuardPlugin support Doctrine 1.1 |
Installing Doctrine 1.1
To get started using Doctrine 1.1, you’ll need to download it. Jonathan Wage provided instructions here which I’ll reproduce below.
From your Symfony project’s root folder:
$ svn co http://svn.doctrine-project.org/branches/1.1/lib doctrine
Now change the location of the Doctrine lib path by editing your ProjectConfiguration::setup() method to look similar to:
public function setup()
{
sfConfig::set('sfDoctrinePlugin_doctrine_lib_path', sfConfig::get('sf_lib_dir') . '/vendor/doctrine/Doctrine.php');
}
Patch Symfony Library
Now you need to patch the Symfony library with the back-ported changes related to Doctrine from the Symfony 1.3 branch. This patch is very simple, and currently only effects one file.
Navigate to your Symfony lib directory. Depending on how you started your project, this is probably the lib/symfony directory in your project.
$ patch -p0 < symfony-1.2.7-doctrine-1.1.patch
Now rebuild your model forms. From your project’s root directory:
$ php symfony cc
Patch sfDoctrineGuardPlugin
If you use the sfDoctrineGuardPlugin you will need to apply another patch.
From your project’s root directory:
$ patch -p0 < sfDoctrineGuardPlugin-doctrine-1.1.patch
Finished!
You should now be able to use Doctrine 1.1 with Symfony 1.2. I haven’t run into any problems using it, however I’ve just gotten started with my new project and haven’t done much of anything yet! If you have troubles let me know.
For anyone on Gentoo, I have a symfony ebuild in my Gentoo Overlay that will install Symfony 1.2 with Doctrine 1.1 support for you.
I’ll try to keep this post updated if I come across anything else that needs to change when using Doctrine 1.1 with Symfony 1.2.
Helpful. Thanks.
Brandon – genious. We upgraded to Doctrine 1.1 yesterday on a huge project and ran into problems all of the place (specifically the problem with DoctrineGuard and the relationship saving problem in the generated forms).
You’ve given new life to our use of Doctrine 1.1 with Symfony 1.2.
Are you tracking any other patches related to Doctrine 1.1 in Symfony 1.3 going forward or is it your feeling that the above patches represent nearly all the necessary fixes?
@Ryan Weaver
I’ve been watching the Symfony issues and commits and haven’t seen anything new. If I do I plan on updating this page and posting a comment.
Unfortunately, I had to put my new project on hold for a few weeks so I haven’t had much opportunity to test for more bugs. Reading through the Doctrine 1.1 changelog, I don’t anticipate anything big – not to mention the Symfony devs are currently working with Doctrine 1.1 in the Symfony 1.3 codebase.
Thank you, this is really great. I can’t wait Symfony 1.3 to use Doctrine 1.1.
Hi guys,
THe roadmap is that Symfony 1.3 will use Doctrine 1.2, and not Doctrine 1.1… =) Just crosses fingers!
We just have a lot of work to do and very small time. If everything goes okay, we’ll launch 1.2 before sf 1.3 and they’ll move externals to new version.
Cheers,
Guilherme Blanco
Guilherme – I’m pulling for you guys with version 1.2. I love Doctrine but hate that I can’t use the latest version of Doctrine with the latest version of Symfony (at least not without some core modifications). We’re getting hurt a little bit by multiple databases in Doctrine 1.0 – I’d love to increase all the way to Doctrine 1.2 with Symfony 1.3.
Anyways, thanks and good luck!
Agreed. You guys are doing an awesome job with Doctrine. I’m looking forward to the next release of Symfony and Doctrine!
I am working on a Fedora RPM for Symfony. This seems to mean that I will have to do a Doctrine 1.1 RPM too and this means that I will have to use your package.
I will report how it goes
Hi,
I’ve applied your patches, it seems better, but I still can’t create new group nor permission, always get :
The item has not been saved due to some errors.
I’ve also applied the second patch given here http://trac.symfony-project.org/ticket/6373 but I’m still stuck with this problem…
If you have any idea, it will be greatful.
(Symfony 1.2.9DEV + Doctrine 1.1 + sfDoctrineGuardPlugin)
Regards
I’ve forgot : I can set permission or a group to a user…
I’ve read you detailed observations and applied the patches.
I still always get “The item has not been saved due to some errors.” when I try to save any of the sfDoctrineGuard forms.
I’m using sf 1.2.8 and doctrine 1.1
Any ideas?
@Alex
I stopped using the sfDoctrineGuard plugin so I’m not sure. You might want to try the patch at http://trac.symfony-project.org/ticket/6373. Sorry I am not more help
Nice one… did not know that. thx
Mariano