Recently I had to develop bunch of complex features on WordPress based website, and the time was running out very quickly. Because I use Zend Framework on regular basis, I decided to incorporate it to my WordPress instance to speed up development.
The task is really simple and can be achieved by creating small plugin.
Firstly, we have to create zf-integration directory (of course you can name it as you wish) inside WordPress plugins directory. After that, we have to create lib directory , and copy Zend library into it. (remember to copy Zend directory from Zend Framework package)
Next we need to create zf-integration.php.
<?php /* Plugin Name: Zend_Framework integration Description: Zend_Framework integration Author: author Version: 1.0 Text Domain: Zend_Framework integration */ set_include_path( implode(PATH_SEPARATOR, array( get_include_path(), realpath(__DIR__.'/lib') ))); require_once realpath(__DIR__.'/lib/Zend/Loader/Autoloader.php'); $autoloader = Zend_Loader_Autoloader::getInstance();
As you can see above, everything is about including proper library path and activating Zend Framework autoloading.
Now we can activate plugin in WordPress admin page, and use Zend Framework classes inside WordPress themes.