cha*_*tsm 4 php configuration yaml symfony1 factories
我在factories.yml文件中设置了以下配置...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
Run Code Online (Sandbox Code Playgroud)
...克服此处所述的"双点"问题.
当我运行以下代码时......
$mailer = $this->getMailer();
$message = $mailer->compose();
$message->setTo('foo@bar.com');
$message->setFrom('foo@bar.com');
$message->setSubject('Testing');
$message->setBody(
$mailer->getRealtimeTransport()->getCommand(),
'text/plain'
);
$mailer->send($message);
Run Code Online (Sandbox Code Playgroud)
......在一个动作中,一切都按预期工作.但是当我从一个任务中运行相同的代码时,我得到一个致命的错误PHP Fatal error: Call to undefined method getCommand- 因为SwiftMailer使用的是默认的传输类而不是Swift_SendmailTransport在factories.yml配置中指定的类.
为什么在symfony任务中没有加载factories.yml配置的任何想法,以及我如何解决这个问题?
您的任务不知道要加载哪个应用程序的factories.yml - 即使您只有一个应用程序.您需要传递这样的应用程序参数:
php symfony namespace:task --application=frontend
Run Code Online (Sandbox Code Playgroud)
要在您的任务中安装默认应用,请更新您的配置,如下所示:
protected function configure()
{
$this->addOptions(array(
new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'),
));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2191 次 |
| 最近记录: |