1
votes

I'm working on a project now that isn't based on Zend Framework, however I would like to use some of Zend's components in it, namely Zend_Form and Zend_Acl.

The question is, what should I do in order to make these components know how to load their classes correctly when they are instantiated.

I suppose spl_register_autoload and set_include_path should be used, just can't figure out how exactly.


Thanks guys,

Zend_Loader_Autoloader::getInstance() plus setting right initial path in set_include_path did the trick.

3
You can just add the parent of /Zend directory to include path and then require_once them OR require_once Zend_Loader_Autloader and use loadClass($class)... - Tomáš Fejfar

3 Answers

3
votes

If it's just two Zend Framework components you want to use, you could include them manually. What I usually do when I need a few Zend Framework components is to load the via autoloader.

You can find several questions and answers on how to use the Zend Framework autoloader on SO, for example this.

1
votes

If you do not want to use Zend_Load_Autoloader::getInstance() to let Zend register its autoloader with spl_register_autoload() you just need to put the folder which contains Zend folder on your.

For example if your Zend components are located in "library/Zend" you have to put "libray" on the path, not Zend. Then you can include files like "Zend/Validate/Interface.php" since they are on your path.

-1
votes

If I understood you correctly, you want to use one copy of Zend Framework in multiple projects. For that purpose, simply edit includePaths.library in your application/configs/application.ini file.