Note: Latest release and documentation are available from component github page.
Allows to efficiently load Zend Framework classes without need to additionally call require_once() or Yii::import().
Unpack extension to protected/extensions/.
Copy ZF directory Zend to protected/vendors/.
You can use special service to get only required
ZF classes.
It is required for this extension and allows to load ZF classes faster.
You can do search-replace from your IDE: search require_once replace to //require_once.
Altenatively you can use console:
GNU:
% cd path/to/ZendFramework/library % find . -name '*.php' -not -wholename '*/Loader/Autoloader.php' \ -not -wholename '*/Application.php' -print0 | \ xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
MacOSX:
% cd path/to/ZendFramework/library % find . -name '*.php' | grep -v './Loader/Autoloader.php' | \ xargs sed -E -i~ 's/(require_once)/\/\/ \1/g' % find . -name '*.php~' | xargs rm -f
We need to register loader before application is run:
define('YII_DEBUG', true); $webRoot=dirname(__FILE__); require_once(dirname($webRoot).'/framework/yii.php'); $configFile=$webRoot.'/../protected/config/main.php'; $app = Yii::createWebApplication($configFile); // you can load not only Zend classes but also other classes with the same naming // convention EZendAutoloader::$prefixes = array('Zend', 'Custom'); Yii::import("ext.yiiext.components.zendAutoloader.EZendAutoloader", true); Yii::registerAutoloader(array("EZendAutoloader", "loadClass"), true); $app->run();
Total 9 comments
Well, in the end I had some issues with Zend trying to include code.
My fixes:
returnstatement in the beginning of Zend_Loader::loadClass.$regexChars = array()or you'll need to disable the foreach below in the file.There are no require, include or include_once in Zend code.EDIT: Actually, there are some of them on the code. They aren't causing me issues, though.
What is about include_once, include and require, should I strip them,too? They appear in many files.
@shark: created an issue on github: https://github.com/yiiext/zend-autoloader-component/issues/1
Please discuss there to not spam people who follow this extension.
@CeBe: Yes, they are.
@shark: is your Zend library under
protected/vendors/Zendand isUri/Http.phpunder there? Make sure you put all files in the right directories.When I want to use this extension, I got an error:
My code:
My log:
Can anyone help me?
you needn't use the sample way to import this ext; just put it to components dir or extension dir , and shorten the deep of dir path:
backwardselvis is right , we should firs import the EZendAutoloader,and then set the static prefixes var :
Leave a comment
Please login to leave your comment.