Search code examples
controlleryiiclass-design

Yii - Extending Controller or CController?


I need to create a class where we should have same methods shared with all my controllers, or almost all anyway.

So, I was looking for extending controller, but THEN, I notice that Controller Class already extends another class CController.

I'm confused.

Should we create our own class and extend CController, or extend Controller, or USE Controller class anyway ?


Solution

  • You can write your common/shared methods in Controller , this class is created for that purpose only (that is your class, do whatever you want to do). no need to create another class.