尝试在 ZF2 项目中使用由 Redis 支持的 PHP-Resque 项目https://github.com/chrisboulton/php-resque。(具体的敏捷性)
我遇到的问题是将 ZF2 命名空间和类结合起来
例如 :
控制器
//Enqueue a worker
$args = array(
'name' => 'EMCP'
);
Resque::enqueue('default', 'phpresque\\V1\\Model\\MyResqueJob', $args);
MyResqueJob 类
namespace phpresque\V1\Model;
class MyResqueJob
{
public function perform()
{
// Work work work
echo "helloWorld";
}
}
resque 给出的错误信息:
ubuntu@/zf2projectname/vendor/chrisboulton/php-resque$ QUEUE=* APP_INCLUDE=/zf2projectname/vendor/autoload.php VVERBOSE=1 php resque.php
** [03:01:37 2014-10-26] Sleeping for 5
** [03:01:42 2014-10-26] Checking default
** [03:01:42 2014-10-26] Found job on default
** [03:01:42 2014-10-26] got (Job{default} | ID: 38fa104b11de81731c15ba9c2f1853ab | phpresque\V1\Model\MyResqueJob | [{"name":"EMCP"}])
** [03:01:42 2014-10-26] Forked 30642 at 2014-10-26 03:01:42
** [03:01:42 2014-10-26] Processing default since 2014-10-26 03:01:42
** [03:01:42 2014-10-26] (Job{default} | ID: 38fa104b11de81731c15ba9c2f1853ab | phpresque\V1\Model\MyResqueJob | [{"name":"EMCP"}]) failed: Could not find job class phpresque\V1\Model\MyResqueJob.
** [03:01:42 2014-10-26] Checking default