How do i nicely decode Laravel failed jobs JSON
Read from failed_jobs table
json_decode the payload from failed_jobs table
$jsonpayload = json_decode($payload);
unserialize the payload command
$data = unserialize($jsonpayload->data->command);print_r($data);//This is the data passed to queue
I'd recommend handling the event as-it-happens and then storing any data you need in your own way. You can use Failed Job Events to capture all failed jobs: https://laravel.com/docs/master/queues#failed-job-events
Or you can use the failed()
function on the job itself: https://laravel.com/docs/master/queues#dealing-with-failed-jobs
Otherwise, Marc's comment seems to make sense to me.
I too was having problem as I did not had direct access to production database.I created a route with auth and my controller returned json with all the failed jobs formatted. Here is controller code. With this I was also able to get formatted stack trace of exception due to which job failed
public function getFailedJob() { #Fetch all the failed jobs $jobs = DB::table('failed_jobs')->select()->get(); #Loop through all the failed jobs and format them for json printing foreach ($jobs as $job) { $jsonpayload = json_decode($job->payload); $job->payload = $jsonpayload; $jsonpayload->data->command = unserialize($jsonpayload->data->command); $job->exception = explode("\n", $job->exception); } return response()->json($jobs); }