Problem on extending Controller

Hi, I would like to create a BaseController and extends other controllers from that. So I’ve created a BaseController with this code:

class BaseController extends CController {


But if I do:

class OtherController extends BaseController {


it gives me this error:


include(BaseController.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

Source File


Both are under protected/controller directory.

Any hint?

you need to do a basic php lesson:

require 'BaseController.php';

You could put BaseController.php in the protected/components directory and it will work perfectly

@jayrulez: it works thanks… now I don’t understand why Yii isn’t designed to put BaseController inside protected/controller

it is more logical to me

if you add the the path of protected/controllers to the php include paths then it would work right away without you having to inlclude/require the file with a line of code. what i suggested works only because the path for components is added through the app config here





maybe you could add a line to it saying ‘application.controllers.*’,

I’m not sure what that effect that would have on your app but if you want a more appropriate place to put your base controller then you could try that. (i was ok with placing it in the components directory)

jayrulez thanks again for the explanation, very clear :)