admin管理员组

文章数量:1287594

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 ponents 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 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 ponents 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.

Share Improve this question edited Jan 8, 2011 at 15:01 munity wiki
2 revs
St.Woland 3
  • +1 for link to RuckUsing- never heard of it – Mchl Commented Dec 30, 2010 at 9:52
  • Well basically it boils down to (if its an PHP Application) if it you can implement the bootstrap process and if the autoloader's can work alongside each other, there a lot tutorials on zend framework and doctrine integration, unfortunately I haven't found anyone that applies to the current Doctrine Beta. The matter with JS and CSS can be pletely encapsulated from the Use of the PHP Application in that regard (imho) - in any case +1 for raising an interesting Point! – Hannes Commented Dec 30, 2010 at 10:09
  • @Hannes As I stated in the question, it's not really HOW to integrate different frameworks, but rather WHAT frameworks to choose for the application. Bootstrapping and writing custom plugins is fine, as long as it's reusable, and I fully take this advantage. But having spaghetti-like architecture sucks, so I would like to see good examples of real-world applications with mature features (CI, DB Migrations etc). – St.Woland Commented Dec 30, 2010 at 10:47
Add a ment  | 

3 Answers 3

Reset to default 9 +100

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 mand line.
  • I also highly remend 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 piling 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-pliant 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.).

  • 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 bination with zend (sorgalla.).

  • 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.

本文标签: phpZendFramework integration with other frameworksStack Overflow