一)如何整合?
// change the following paths if necessary
$yii = dirname(__FILE__).'/framework/yii.php';
$config = dirname(__FILE__).'/protected/config/main.php'; // remove the following line when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3); // ---------------------------- another way to load ZF2 libaray ----------------------------
// load zf2 framework as 3rd path library of yii
/* defined('ZEND_PATH') or define('ZEND_PATH', dirname(__FILE__).'/framework/vendors/Zend/');
require_once ZEND_PATH . 'Loader/AutoloaderFactory.php';
Zend\Loader\AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' => array(
//'autoregister_zf' => true
'namespaces' => array(
'Zend' => ZEND_PATH,
),
)
)); */
// --------------------------- end --------------------------------------------------------- // load yii
require_once($yii);
$yii = Yii::createWebApplication($config); // load zf2 framework as 3rd path library of yii.
// Please known that another way to load the zf2 libaray has marked in this file
// see -- line:12-24 --
Yii::$enableIncludePath = false;
Yii::setPathOfAlias('Zend',Yii::getPathOfAlias('system.vendors.Zend')); // run it
$yii->run();
修改index.php文件。来源:http://yiiframework.ru/doc/guide/en/extension.integration