Hi,
I’ve successfully configured the Yii console app for sending perioding emails. Here is the working console.php config file.
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Console Application',
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.content.*',
'application.modules.content.models.*',
'ext.yii-mail.YiiMailMessage',
),
// application components
'components'=>array(
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType' => 'smtp',
'transportOptions'=>array(
'host'=>'smtp.gmail.com',
'username'=>'user@gmail.com',
'password'=>'pass',
'encryption'=>'ssl',
'port'=>465,
),
'logging' => false,
),
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=mydb',
'username' => 'root',
'password' => 'rootpass',
'emulatePrepare' => true,
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
'enableProfiling' =>true,
'enableParamLogging'=>true
),
),
);
And I have this Command class.
class SendEmailCommand extends CConsoleCommand
{
public function actionComments()
{
// located at /protected/models/post.php
$post = new Post; // WORKS!
// located at /protected/modules/content/models/settings.php
// $settings = new Settings; // This DOES NOT WORK <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />
echo 'Send Comment';
}
}
I can run it with cronjobs (yiic sendemail comments) and it works fine. I can instantiate the model classes like Post (as you can see above) which is located under /protected/models. Everything is ok
But as you can also see, I cannot instantiate the models located within the modules. I receive an error which says: Send Commentexception ‘CException’ with message ‘Property “CConsoleApplication.settings” is not defined.’ in /home/user/yii/framework/base/CComponent.php:131
But I have correctly indicated in the config file to import all the
'application.modules.content.*',
'application.modules.content.models.*',
What can be a problem? I think there is something I’m missing.