How To Include Classes Under Yii:app()->

Hi,

In the old Yii / PHP I could access my components classes by doing the following …

  1. Create an Email class a stick it in components folder.

  2. Put the following in the main.php …




// autoloading model and component classes

'import'=>array(

	'application.models.*',

	'application.components.*',

),






'email'=>array(

	'class'=>'Email'

),



  1. Call the email class in the app controller like so …



Yii::app()->email->someFunction();



Now when I do this in my app it says …




Internal Server Error

Property "CWebApplication.email" is not defined.


An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.


Thank you.



It never use to do this, so what is wrong now? Does anybody know how to do this using the new Yii / PHP?

Anyone know how to do this?

Not sure. Try:




'email'=>array(

	'class'=>'application.components.Email'

),



You didn’t place the config inside ‘components’ in config/main.php:




'components' => array(

        ...

        'email'=>array(

              'class'=>'Email'

        ),

        ...

)






That should work and if it doesn’t, your email component might be placed inside a directory on its own and in that case either take it out directly to the ‘components’ directory, or be sure to update your ‘import’ section accordingly:





'import'=>array(

        'application.models.*',

        'application.components.*',

        'application.components.emailDir.*',

),



Thanks everyone, the problem was as Joblo stated in that I did not place the email class code inside the components array section.