有个邮件发送的消息队列,新建了Crontab自定义指令
代码如下:(同样的代码通过http访问URL运行没有问题)
protected function execute(Input $input, Output $output)
{
$type = $input->getArgument('type');
if($type=='Process_Notice_Email'){
$output->writeln($type);
ini_set('default_socket_timeout', -1); //不超时
$Redis=new ExtendCommon\MyRedis(); // 创建redis类
$Sendmail=new ExtendCommon\Sendmail(); // 创建邮件发送类
while (true) {
try{
$result=$Redis->brpop('Notice_Wechat'); //出队列,阻塞模式
if($results){
$content=$results['1'];
$res=$Sendmail->send_email($content); //发送模板消息
$output->writeln("Error:".$res);
}
usleep(100000); //睡眠0.1秒
}catch(Exception $e){
$output->writeln("Error:".$e->getMessage());
}
}
}
}
运行php think Crontab Process_Notice_Email提示 Class 'Redis' not found
redis是自己封装的
提示错误行代码如下:
if(self::$redis==null){
self::$redis = new \Redis();
}
不知道怎么解决??? 最佳答案
