基本流程:
1、使用Gii Module Generator 生成模块 如: DeliveryAddress 2、修改protected/config/main.php 挂载生成的模块 ..... 'modules'=>array( .... 'DeliveryAddress', ..... ), ...... 3、访问模块 weburl/index.php?r=DeliveryAddress使用模块别名:
1、同 基本流程 2、修改main.php配置文件 ..... 'modules'=>array( .... 'deladdr'=>array( 'class'=>'application.modules.DeliveryAddress.DeliveryAddressModule', ), ..... ), ...... 3、访问模块 weburl/index.php?r=deladdr 提示错误:CException Alias "DeliveryAddress.models.*" is invalid. Make sure it points to an existing directory or file. 解决方案: 修改模块类文件protected/modules/DeliveryAddress/DeliveryAddressModule.php文件 中的模块初始化代码 .... //设置路径别名 Yii::setPathOfAlias('DeliveryAddress', realpath(dirname(FILE))); //添加以上代码 $this->setImport(array( 'DeliveryAddress.models.*', 'DeliveryAddress.components.*', )); ......保存后刷新访问页面
weburl/index.php?r=deladdr Over