例如现有两个 Yii 项目,分别是 test1 和 test2。在 test1 中,已经有模型了,test2 直接调用 test1 中的模型,其实添加个别名,然后修改下配置即可。
先在 index.php 入口文件里 require_once($yii); 后面加上:
Yii::setPathOfAlias('pubModels', dirname(__FILE__) . '/../test1/protected/models');
Yii自定义模型路径