Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

extjac's avatar

Queue Questions

1 - How do you make the queue work in production. Ex: AWS EC2 ? Do you create a cronjob that run php artisan queue:work every min?

2 I have SendReminder email function (see below) that works ok until I use "implements ShouldQueue". The moment I include "implements ShouldQueue" the variables that I send to a Transformer message function, stops working. Basically, the content of the email comes empty. However, if i don't use "implements ShouldQueue" the email content is delivery as expected.

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SendReminder extends Mailable implements ShouldQueue
{
    
    use Queueable, SerializesModels;


    protected $booking;

    public function __construct( $booking )
    {
        $this->booking = $booking;
    }

    public function build()
    {
          return $this->from( '[email protected]'  )
        ->markdown('email.booking.reminder')
        ->subject( 'This is a reminder for event '. $this->booking->item->name )
        ->with('body', $this->transform( $this->booking ) ) ;
    }

    private function transform( $booking )
    {
        return \App\Transformers\NotificationTransform::body( $booking, $booking->body);
    }



}


0 likes
2 replies
martinbean's avatar

1 - How do you make the queue work in production. Ex: AWS EC2 ? Do you create a cronjob that run php artisan queue:work every min?

@extjac No. Queue workers are long-running processes. You should boot them when you deploy, and have something like Supervisor ensure it continues running if you’re self-hosting using something like an EC2 instance.

2 I have SendReminder email function (see below) that works ok until I use "implements ShouldQueue". The moment I include "implements ShouldQueue" the variables that I send to a Transformer message function, stops working. Basically, the content of the email comes empty. However, if i don't use "implements ShouldQueue" the email content is delivery as expected.

Make your properties (i.e. $booking) public and they should then be serialised along with the queue job.

1 like

Please or to participate in this conversation.