And remember, to use various Zend Framework components in another project, you just need to have the Zend
library somewhere on your include_path
. Copying the whole thing may seem overkill to use one component, but it's only disk space. Having those files there doesn't affect performance unless they are called upon. And this way, you don't have to sweat the dependencies, like Zend_Exception
and its various component-specific subclasses.
So, for example, if you have a folder myapp/lib
to contain your external libraries, you simply make sure that your include path contains that lib
folder and copy the Zend
folder into it as myapp/lib/Zend
.
Then to use a component like Zend_Translate
, all you have to do is something like the following:
require_once 'Zend/Translate.php';
$options = array(
// your options here
);
$translate = new Zend_Translate($options);
With some kind of autloading mechanism in place, you can avoid even the require_once
call. Setting up autoloading is as easy as putting the following in some kind of common/bootstrap file:
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
Then any classes that follow the PEAR 1-class-1-file naming convention can be loaded without explicitly adding any require/include statements.
If disk-space really is a concern and you really don't want the whole Zend
library, then you could investigate a packageizer, like Jani Hartikainen's Packageizer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…