Alex Rivera | Logout

ZendFramework integration with other frameworks

Asked 2010-12-30T09:42:48.733
13

I want to make this question a guide for those interested in ZendFramework integration with other libraries/frameworks. Searching over StackOverflow doesn't give a broad view on the subject.

The question is: which libraries/frameworks do you use in your current ZF-based project? what are the best practices for ZF-based project architecture?

I don't mean any components that are already a part of ZF. Please give a description of aditional frameworks you have integrated (like RuckUsing, Smarty, or Doctrine). It also applies to any GUI frameworks (perhaps you use a CSS framework), as well as JS frameworks (not just jQuery or prototype, but rather some advanced structures).

The main requirement: it has to be a ZendFramework project.

Additional bonus will be given to answers that describe performance optimization.

UPDATE

Every answer as informative as @BryanM's will be considered for additional bounty award.

Edit
Report

1 Answer

9

I use Doctrine 2 in my Zend Framework projects. It's easy to use and fits in seamlessly. The basic steps to integrate it are:

  • Write a resource plugin that will initialize a Doctrine 2 EntityManager using configurations options in application.ini. An example of one can be found in Benjamin Eberlei's DoctrineExtensions.
  • Rather than rely on a global registry (Zend_Registry) to store the EntityManager reference, I rely on a simple depedency injection solution as described here to provde the instance to my controllers.
  • I rely on Doctrine's Event system to create re-usable 'behavior' classes to do things like update timestamps or validate data.
  • I keep all my Entities and business objects in my application's 'models' folder (under it's own namespace), and everything else in in my library folder. I heavily use PHP 5.3 namespaces to keep things organized.
  • I use Doctrine's new-ish Migrations library to handle updates to the database via the command line.
  • I also highly recommend creating a detailed build process in Phing in order to handle library dependencies, automated unit testing and running migrations that can be integrated into source control or a CI Server. Also good for compiling Javascript or CSS if you're using one of those frameworks.

These practices aren't just good for Doctrine, they'll be handy anytime you're trying to built a site's architecture. I think that Zend's biggest assets in extensibility are Resource plugins and ActionHelpers / Controller Plugins.

answered 2010-12-30T21:14:36.183

Your Answer