What's Yii's equivalent to other MVC's Helpers and Libraries?

What’s Yii’s equivalent to other MVC’s Helpers and Libraries?

Are they Components and Extensions? what’s their difference?

What I want to do is code some functionality that will be available from any Controller.

How do I load and use them?

The documentation is not very clear about this.

i’m working like this:

components is all my stuff which i would only use in this project (cause it’s very special)

and extensions are the helpers from other people or my own things, which are very generic and could be published as extension on the page

if you want to enable them globally edit the config/main.php and set the component (components.* is imported by default) or extension inside the import…

if you did so, just use the classname inside your code and yii will autoload that file (which must have the same name as the classname)

you also can import them with Yii::import() or set the includes inside a module’s entryfile

but if you just want to extend a controller, following might help you: http://www.yiiframework.com/forum/index.php?/topic/11482-hook-for-application-wide-code/page__fromsearch__1

for me the modules are like librairies (using their components folder)

or I think you can create a directory in your application (for example generalcode) and add it in main (generalcode.*) so it’ll be available everywhere

in fact, I found that

> if you want to access your code like a controller create a module

> if you have independant views files you want to call in another module create a module (you can render a module file in another module)

> if these is classes to inheritance or add features, and want to use it in modules, create an extension

hope it’ll help