Separate Controller Class definition

One of my controller contains over 800 lines, I want to separate the definition is possible.

I tried to use CBehavior, the stucture pretty much like this

/protected

----/components

--------/ASDF

------------AjaxHandler.php --> CBehavior contains ajax related code

----/controllers

--------ASDFController.php --> Controller where AjaxHandler is attached

I’ve moved some ajax related code to AjaxHandler.php. I want to ask if this is a good approach, need inspirations here :lol:

Unfortunatelly “Actions by Behavioring” isn’t supported by Yii


http://www.yiiframework.com/forum/index.php?/topic/10652-actions-by-behavioring/

Any Ideas ? : (

You can create more than one controller, for example.

Anyway, if you really need to have 20 actions for one controller, I think that there are no other solutions. Don’t be aftaid if the controller is long, the code of the actions is independend from each other, so feel free to consider the lenght of an action as “value to optimize”.

If yoy have 4 action of 200 lines each, try to rebuild the code creating some widget or some component, pushing some data elaboration in model (this is ALWAYS a good choice).

If you have 40 actions of 20 lines each, this is absolutely normal. If you so much don’t like long file, your only chance is to separate the actions in different controllers.