Laravel 5.4 Queue Email

239
January 13, 2018, at 07:56 AM

I'm trying to use Laravel Queues for sending emails using the database driver, I have already configured it, run the migration for the "jobs" table and when I run this:

Mail::to($user->email)->queue(new CompraRealizadaAdmin(Cart::content(), $monto_descuento, $envio, $user_array, $direccion, $compra));

A record is added on the "jobs" table, but, how do I run the queue on the database table?, I understand that for triggering it at the moment it is added, I will need to run the command php artisan queue:listen, or if I need to run all the ones that are still on queue, I will use php artisan queue:work.

But how do I run the command without the need to open terminal and keep it open until it has finished...?

I had the idea of creating a schedule and run it every minute and just execute the code: Artisan::call('queue:work'); but that does not work.

Any ideas?

Answer 1

Depending on your needs, preferences and your target OS you can use

  • supervisord (cross platform)
  • upstart / systemd (linux)
  • launchd (OS X)

or alike services to manage your queue worker processes.

In fact Laravel documentation explains in great detail how to install and configure supervisord for this.

Answer 2

It depends on which OS you are working on for Ubuntu or linux you can use supervisor and hup.

butt be careful you have to run hup every time you reboot your machine.

thats how you can run this command. hup php artisan queue:work.

Hope this helps

Rent Charter Buses Company
READ ALSO
Symfony 4: doctrine in command

Symfony 4: doctrine in command

I am using symfony 4 and I want to access a repository for an entity if I am in the Command classThere is not a function getDoctrine or something

447
why the while loop runs once?

why the while loop runs once?

the following code is only running once , while the number of times it should run is 4 , any help ?

231
Trying to get property of non-object Notice in custom avatar function for Wordpress

Trying to get property of non-object Notice in custom avatar function for Wordpress

The following custom avatar functions works fine, but I get the following notice

241
Illegal string PDO fetch() vs fetchAll()

Illegal string PDO fetch() vs fetchAll()

When I try to call fetch() after executing a PDO statement, I get the following warning:

421