Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Zend Framework components without the actual framework?

I was wondering if anyone knew how to use some components of the Zend Framework without having to actually use the framework. For example, I would like to use their Zend_Validate components, but don't want the overhead of the framework as it's a small one-page script.

Can this be easily done, and if so, are there guides/tutorials on how to accomplish it?

like image 394
Mike Trpcic Avatar asked Sep 10 '09 01:09

Mike Trpcic


3 Answers

Zend framework components are intentionally designed to be loosely couple from the framework itself.

The component structure of Zend Framework is somewhat unique; each component is designed with few dependencies on other components. This loosely coupled architecture allows developers to use components individually. We often call this a "use-at-will" design. [from here]

Here's a tool for pulling out specific components and their dependencies to use in your application.

like image 83
Joel Hooks Avatar answered Oct 31 '22 07:10

Joel Hooks


I've just grabbed the whole Zend package, and used pieces of it. It always seems I end up using more of it as time goes on, so I keep it up to date even if I'm not using some of the MVC stuff in one project or another. Holding on to the whole thing makes you not have to worry about the dependencies (and how they might change down the road).

like image 45
Justin Avatar answered Oct 31 '22 09:10

Justin


Zend framework components while being loosely couple are still coupled. If you would to use Zend_Mail component for example - that would actually also require:

  1. Zend_Mime
  2. Zend_Exception
  3. Zend_Validation

Zend_Validation will be loaded for the mere reason of validating email address domain.

So - best bet would be to include entire Zend library. By pulling only several components - you'll soon end up in "dependency hell" especially as API changes (though that doesn't happen too often).

Also - starting from version 2.0 you must use some auto-loader to load Zend components as all require calls will be removed from PHP classes.

like image 28
ThatGuy Avatar answered Oct 31 '22 07:10

ThatGuy