Use queue:listen instead of queue:work when developing locally
Laravel has a powerful queue system in place and when you are utilizing queues you need to run workers. Typically, in production you would use the
queue:work command to start them but these are considered long-lived processes and store the booted application state in memory. So this means after you make any code changes you’ll need to restart them that way they have a fresh state.
When developing locally this can get burdensome, and if you are like me you might forget to restart them. Leaving you scratching your head why the changes you made aren’t working. I’ve personally wasted a lot of time doing this and I think it’s something easy to forget. To make this a problem of the past Laravel provides a
queue:listen command designed for working locally. It doesn’t boot the application state in memory so you never have to restart the queues when making code changes.
Both commands are equivalent as well.
php artisan queue:work --queue=high,default
Is the same as:
php artisan queue:listen --queue=high,default
Keep in mind though that you should never use
queue:listen in production because it is significantly less efficient than the
Credit: Source link