Laravel如何从工作中获取数据?

问题描述 投票:0回答:1

我得到了Laravel队列(使用Redis)。我需要从这个队列中获取工作。我想做:

$queues = Queue::getRedis()->zrange('queues:confluence:delayed' ,0, -1);
foreach ($queues as $job) {
    $tmpdata = json_decode($job);
    $command = $tmpdata->data->command;
}

但是在$command我得到了这个字符串:

“O:16:\”App \ Jobs \ TestJob \“:8:{s:7:\”\ u0000 * \ u0000name \“; s:5:\”12345 \“; s:6:\”\ u0000 * \ u0000job \ “; N; S:10:\” 连接\ “; N; S:5:\” 队列\ “; S:10:\” 合流\ “; S:15:\” chainConnection \“; N; s:10:\“chainQueue \”; N; s:5:\“delay \”; i:5; s:7:\“chained \”; a:0:{}}“


> It does not seems like json or anything else (what I can parse to
> normal object/array). How can I get job data in this way?
laravel queue jobs
1个回答
0
投票

您看到的数据已序列化。您可以将其反序列化为:

 $command = unserialize($tmpdata->data->command);

虽然注意,并阅读此命令的文档,因为它是一个潜在的安全风险:https://www.php.net/manual/en/function.unserialize.php

© www.soinside.com 2019 - 2024. All rights reserved.