Hook for application wide code?

Hi all,

after extensive tests of several frameworks I have decided to work with Yii. So far I am quite happy with my decision!—There is only one question which I cannot find any answer for so far:

Please, could you tell me where the best place/what the best way is to hook in code which should be executed application wide? I am thinking along the lines of authentication/authorization or I18n that I would like to keep in a central location and not repeatedly write/maintain in each controller…

A module? A base controller? A plugin? … I thought you might like to share your best practices and point me in the right direction.

Thanks in advance for your kind help and patience with a Yii-newbie.

Cheers,

Mellou

in general for hooking in:

i use the index.php to include my shortcut file and switch between developement and production config

and i use a basecontroller (components.controller) to define system-wide behavior - so all my other controllers are inheriting from that controller

stuff like i18n should be in that controller (inside init() function) cause you need the configuration and basic yii stuff loaded first…

very global pre-initialisation things can go in the index.php

Hi balrok,

great, thanks for sharing. Makes a lot of sense. =)

Cheers,

Mellou