我有一些组件我想让它分开,目前我的组件看起来像
-protected/components
-GeneralFunction.php
-CustomFunction.php
我打电话给我的配置:
'components' => array(
'general' => array('class' => 'GeneralFunction'),
'custom' => array('class' => 'CustomFunction'),
),
上面的代码工作正常但我想分离我的组件的前端和后端,如:
-protected/components
-frontend
-GeneralFunction.php
-CustomFunction.php
-backend
-GeneralFunction.php
-CustomFunction.php
我打电话给我的配置:
'components' => array(
'general2' => array('class' => 'frontend.GeneralFunction'),
),
TestController.php
function actionTestComponent(){
echo Yii::app()->general2->test(); exit;
}
我收到此错误消息:
2017/12/19 11:17:54 [error] [exception.CException] CException: Alias "frontend.GeneralFunction" is invalid. Make sure it points to an existing directory or file. in C:\xampp\htdocs\yii\framework\YiiBase.php:348
请帮帮我..
答案 0 :(得分:1)
经过大量研究后我发现了这个:
'general2' => array('class' => 'application.components.frontend.GeneralFunction'),