Config Option to include files

Is there a config option to include files so i can use path aliases to tell Yii to automatically include the file?

example (see ‘include’):

return array(

   'name'  => 'My Web Application',

   'include' => 'yiishared.includes.common.php',


   'components' => array(



If you want to automatically load a file you could either include it as a component in the preload property in your config, or you could use a simple require statement in your config or index. The first option is the most elegant way.

can you give me an example on how you would include a file on the preload? I am under the impression preload is strictly for components and these are not Components?

Obviously a require does it but i’m also not looking for a require as it has to use a Yii Alias

I’m not sure if this is the ‘right’ way, but as far as I know you can only preload components, so making your file a component is a way to do it.

I’ve created an extension that is loaded as a component, if you check the setup instructions you’ll get an idea how to do it:

But as I said, you could also include it in your config or index file, this is the preferred way to include helpers:

thanks but again i’m not loading components and i know how to create components. i’m just asking if Yii has a config option built in.

Have same Problem cause it seems only Classes are auto-loaded.

So I don’t shame to create require in config/main.php at top of the file:

$basePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..';

require_once $basePath . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'common.php';

Ok, it’s included while running in a Class, but it works!