How to autoload a custom component/class in Yii 1.1

In the file config/main.php add ‘application.clases.*’ to import all the classes in the protected/clases folder.

You can see in the example above that the class Name.php is added. This is the class (a simple one):

And now you can call it from the view that you want, like this:

Now, if you want to integrate some clases that are outside of the framework yo can do it like this:

Adding this to
Yii::setPathOfAlias(‘customName’, dirname(__FILE__).DIRECTORY_SEPARATOR.’../app/’);

where “app” is a folder outside the framework (a level up folder)

 

And finally you can modify config/main.php, adding this to the import array:

‘clasesGerman.clases.*’,