1

Is it possible to load Zend Framework in some external script or system?

For example I would like to use ZF full functionality in my CMS.

Your help would be appreciated.

2
  • It is full possible, just create a folder for ZF in your project file'system and include ZF's librairies as any other else, Commented Jan 25, 2013 at 9:50
  • what is your CMS? If it's not a secret... :) Commented Jan 25, 2013 at 13:22

1 Answer 1

1

It is possible to include the ZF in any PHP application. As the ZF team states it in the manual the ZF components are loosely coupled so you can use only certain parts of the library in your application.

What I usually do is I stack the ZF's autoloader to the spl_autoloader and register only the "Zend_" name space with the ZF autoloader. In that way if your CMS' autoloader fails to include the ZF class you are using its gonna proceed to the Zend's autoloader that will do the job.

If you want to use the MVC of ZF for certain request in you CMS it is also possible, although is a bit tricky.

I did include ZF once in a Joomla 2.5 component. In most CMS' any module, component, plug-in, etc, is executed by including one file and whatever is in that file will be proceeded.

With Joomla I simply took the Zend_Controller_Front and dispatched it in the above mentioned file. I attached one plug-in (extending Zend_Controller_Plugin_Abstract) to the front controller on the preDispatch hook (method) and I set the controller, action and module (if any) manually in that hook, taking information from php's $_GET or $_POST depending on how your CMS processes requests.

Setting the ZF autoloader in the beginning of your script and unsetting it in the end will do the job of including the necessary files for ZF to work.

Don't forget to include the ZF in PHP's include path.

Hope this chaotic post helps :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.