Chinmay235
Chinmay235

Reputation: 3414

How call components in Yii 1.1

I have some component I want to make it separate currently my components looks like

-protected/components
    -GeneralFunction.php
    -CustomFunction.php

and my config I have called:

'components' => array(
   'general' => array('class' => 'GeneralFunction'),
   'custom' => array('class' => 'CustomFunction'),
),

Above code is working fine But I want to separate frontend and backend of my components like:

-protected/components
    -frontend
        -GeneralFunction.php
        -CustomFunction.php
    -backend
        -GeneralFunction.php
        -CustomFunction.php

and my config I am calling:

'components' => array(
   'general2' => array('class' => 'frontend.GeneralFunction'),
),

TestController.php

function actionTestComponent(){
    echo Yii::app()->general2->test(); exit;
}

I am getting this error message:

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

Please help me..

Upvotes: 1

Views: 409

Answers (1)

Chinmay235
Chinmay235

Reputation: 3414

After lots of research I found this:

'general2' => array('class' => 'application.components.frontend.GeneralFunction'),

Upvotes: 1

Related Questions