ZendFramework integration with other frameworks
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.
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.
Also remember HtmlPurifier for HTML sanitization, typically parsing user-provided markup, based upon a whitelist of allowable tags, and producing standards-compliant output markup.
It can be used as a first line of defense against XSS attacks. Note that Zend_Filter_StripTags
is not sufficient for this purpose.
ZendX_JQuery (a tutorial is available on zendcast.com).
Although, it's a ruby application, we use webistrano to deploy php projects.
If your web application has to do full-text search on a large scale, i would use sphinx in combination with zend (sorgalla.com).
If you want to use those new NoSQL-Databases like MongoDB, you could use morph as high level php-library. I just copied the files to 'library' and told the autoloader to load the files: autoloaderNamespaces[] = "Morph_".
ZF_Debug is a nice debugging toolbar for development.
精彩评论