views:

127

answers:

2

how can i get started with Doctrine 2 + ZF? any tutorials or resources?

on a side note, i hear ZF2 will use Doctrine as its models, true?

+1  A: 

What's nice about working with ZF and Doctrine 2 is that there's very little that needs to be done to integrate them. Essentially, you just need access to an instance of Doctrine 2's EntityManager that's set up during the applications bootstrap, as well as make sure the Doctrine namespaces are getting loaded in your index.php (You'll need to use Doctrine's ClassLoader for this, Zend_Loader does not support namespaces yet).

You can instantiate your EntityManager manually in the bootstrap, or even easier, through a Resource Plugin (which makes it easy to store the database config in application.ini). You can pretty much follow the documentation on configuring and obtaining an Entity Manager in Doctrine's manual, and just have the init() method in your bootstrap resource return the instance.

You're probably going to want to depend highly on dependency injection for passing the EM to the various objects that need it. For an easy way to pass bootstrap resources into your action controllers, see this article on creating a simple resource injector.

I've been using Doctrine 2 with ZF since it's been in alpha, and have found it quite pleasant to work with.

Bryan M.
+1  A: 
Christoph Strasen