October 29th, 2009
Posted by Fred Wu
Even though the method outlined in my previous post would still work, I thought I’d post a cleaner one to handle the auto-load of Zend Framework classes in Kohana.
The code works with Zend Framework 1.8+, where a new Autoloader class has been introduced.
You can put the code in an appropriate place in your application, it could be in the base controller, or if you’re using Kohana 3.0, in the bootstrap file.
You now no longer need to manually ‘include/require’ Zend Framework files. :)
if ($path = Kohana::find_file('vendors', 'Zend/Loader')) { ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.dirname(dirname($path))); require_once 'Zend/Loader/Autoloader.php'; Zend_Loader_Autoloader::getInstance(); }
Personally, for version 3 I would create a module and use the init.php file in that module to contain your code above.
Thanks for this guys.
What would be the simplest way to integrate Doctrine into Kohana-3?
I’ve done a lot more flexible autoload for ZF, without renaming the library files and folder or searching and replacing the code in them. Just overwritten the original auto_load function with my own.
Zend Framework with Kohana PHP 3