Zend Framework 2 is getting close to release, and among the changes are new ways to handle dependency injection, and new ways to work with third-party code as modules. Rob “Akrabat” Allen has updated his iconic Getting Started with Zend Framework tutorial for ZF2, and it’s a great place to start.
After working through that tutorial, the next thing I wanted to do was figure out how to get the Doctrine 2 ORM up and running.
This article shows how to set up and use Doctrine 2 in Zend Framework 2, by extending Rob’s Getting Started tutorial to use Doctrine instead of Zend_Db.
See the complete source code for this tutorial on Github.
Updated 20 September 2014: Brought up to date with current versions of the ZF tutorial and updated Doctrine composer package name.
Updated 18 June 2012: Added support for new Doctrine config file format.
Updated 2 June 2012: Added support for ZF2 beta 4 and the new composer-based installation methods.