When you need to integrate with other frameworks (e.g. Zend Framework), you have to follow these steps:
- Create protected/vendors/ (e.g. protected/vendors/Zend)
- In your action/controller put
Yii::import('application.vendors.<frameworkName>.*')
- If you need more, than just 1-2 classes (e.g. full package in the framework), you should register it's autoload method. Most frameworks implement their own autoload, that is different from Yii's one.
I saw this hint in this forum thread and adopted it to Zend:
require_once 'Zend/Loader/Autoloader.php';
spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('Zend_Loader_Autoloader','autoload'));
spl_autoload_register(array('YiiBase','autoload'));
Idea is the following. You unregister Yii's autoload function, then register framework's one and then Yii's one again. This leads to the effect, when php is trying to use 3rd party autoload first and loads correct classes. If none found (because you actually called Yii class), it tried Yii's autoload. So everything is OK :)
What is Yii Autoloader?
Maybe I am a beginner, but I haven't seen anything called Yii autoloader after reading the Guide.
Are you talking about Yii::import()? or
return array(
'class'=> application.component.xxxx,
...)
?
@nettrity
For autoloading concept check the PHP documentation
http://php.net/manual/en/language.oop5.autoload.php
@mdomba
That is PHP autoloader. How does it related to Yii?
@nettrity
Chek all the PHP documentation about it...
If you have read the PHP documentation... you know that by using spl_autoload_register() you can register a custom auto-loading method to be used by PHP script...
Yii registers the method YiiBase::autoload() to be used as an autoload by PHP scripts - http://www.yiiframework.com/doc/api/1.1/YiiBase#autoload-detail
And what this wiki say to do (check again the code above) is to unregister that Yii method... register the zend autoloader... and then again register the Yii one...
Hope it clears your doubts..
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.