DEV Community

Cover image for Setting Up The Laravel Queue Worker on Heroku
Efe Omoregie
Efe Omoregie

Posted on

Setting Up The Laravel Queue Worker on Heroku

Heroku photo

You've successfully deployed your Laravel App on Heroku. Next you figure out you can't start your queue workers like you normally would on your traditional apache/nginx servers. You try all the available commands but they all don't seem to work.

Here's how to set up a Laravel queue worker on Heroku to allow your long process task to run in the background.

All you have to do is enter a configuration for the Procfile that’s located in the root level of the project directory as well as spin up a new Heroku dyno instance.

To define the queue, you have to name the queue first (which can be anything that you want, for this example "worker")

worker: php artisan queue:listen

and then proceed to chain it with the

php artisan queue:work

command to ensure it's running.

You can also pass any of the flags that are provided by the

queue:work

command depending on your needs.

Assuming your Laravel app has already been deployed, your next move is to run

heroku ps:scale web=1 worker=1 --app your-heroku-app

from your command line, and this will ensure that your Laravel application has another dyno called worker. Once you have done that, Heroku will be able to process your Laravel queues.

Top comments (0)