How To Extend Capplication Class

hello all,

can you please help me a little, how can i extend capplication class, i need some core thing there, that will be common in WebApplication and ConsoleApplication, and i also don’t want to rewrite CWebApplication code. for example see this code

"WebApplication extends CWebApplication" and "ConsoleApplication extends CConsoleApplication", and i want something common in both so i have to "Application extends CApplication", but how CWebApplication and CConsoleApplication extends from this "Application"

i want my code to be suppoted in php 5.3,

do you have any idea, best pratices, any solution,

Thanks, all for this great framework

is there someone who can help me?

If you want your code to work for both a web and console app, the best solution is to write a behavior for you app model. Then you can have your logic in there

just a day ago i remembered this, how can i forget this ! damm!

Thanks brother !

There’s a lot of options here, Meghraj.

You can use the Controller class (in protected/components), or you can write an application component. Or a behavior.

It depends.

Yii is flexible enough. ;)

Thanks jacmoe, hi jacmoe do know something better approach for modules, i am trying to load all my modules once, when application starts, so all enabled modules will load and according to their dependency, so they can communicate with each other, do you know any good example of code where application is divided into modules, like a base module will load front page, and other module will get a chance to inject their items in menus, etc trough event, hook or anything,

please suggest me some good examples of code if you know any, or something about idea,

Put the module names in the preload array in your main config.

Besides that, I am not really using modules much myself, as I always end up making them application specific anyway (and thus defeating the purpose).

You can use CAction to attach common functionality to controllers. I think that’s better.

Browse through our wiki; there’s a lot of good information there.

Or search for it. Google search is better than the forum search (which kind of sucks).

Github/Bitbucket is also a good place to look for Yii code…

Thanks jacmoe.

Model behaviors are also great, btw. :)

The Yii Guide is recommended - find it under Documentation / tutorials.

i know, its really great and similar to php traits , and i am also watching code of yupe-cms, zurmo which are most powerfull apps buid on top of yii (as i see yet)