Integrating with other frameworks

You are viewing revision #1 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.

next (#2) »

When you need to integrate with other frameworks (e.g. Zend Framework), you have to follow these steps:

  1. Create protected/vendors/ (e.g. protected/vendors/Zend)
  2. In your action/controller put Yii::import('application.vendors.<frameworkName>.*')
  3. 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 :)

4 1
7 followers
Viewed: 28 327 times
Version: Unknown (update)
Category: Tutorials
Tags:
Written by: KJedi
Last updated by: KJedi
Created on: Jun 17, 2009
Last updated: 15 years ago
Update Article

Revisions

View all history