如何在Yii 1.1中调用组件

问题描述 投票:1回答:1

我有一些组件,我想让它分开,目前我的组件看起来像

-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

请帮我..

php yii
1个回答
1
投票

经过大量研究后我发现了这个:

'general2' => array('class' => 'application.components.frontend.GeneralFunction'),
© www.soinside.com 2019 - 2024. All rights reserved.