Laravel queue job does not work in background

laravel

Solution

First, you do not want to use `Artisan::call` on 'queue' commands within your dispatcher.

You should open your terminal and execute: `php artisan queue:listen --timeout=0 --tries=1` and you should let it be. Then you can visit your page where $this->dispatch or even better dispatch method will be called. Code on that page should be: `dispatch(new WelcomeEmail($user));`

On your production server, you should use supervisord to monitor your `php artisan queue:listen` command, to make sure that it's up and running all the time.

For further reading please visit: https://laravel.com/docs/5.2/queues

Problem

Hy! I have an application where I have to send some emails at certain actions (such as user creation, etc.). Problem is they are not running in the background, instead I have to wait until the process is done, and then it redirects me to another page. I use `database` driver with `queues`, `Laravel 5.2`. My code for email, for exp, after user creation: ``` $this->dispatch(new WelcomeEmail($user)); Artisan::call('queue:work'); ``` where `WelcomeEmail` is the job that is pushed on queue. This type of code is placed in all the places where I want an email to be send. What is wrong?

Original source