Automatically running Laravel queue worker and scheduler using PhpStorm

    $ October 6, 2022

    I recently switched to Laravel Valet instead of Laravel Sail. However, I wasn't sure on the best way to run Laravel's scheduler and queue worker locally when working on my projects. Luckily, PhpStorm has a feature called startup tasks which work great for this use case.

    1. In PhpStorm config, head to Tools > Startup Tasks

    2. Add a new configuration and select Shell Script

    1. Give the run configuration a name (e.g. "Laravel Scheduler")

    2. Select Script text and enter the artisan command (e.g. php artisan schedule:work)

    3. If you want these tasks to appear in the "Run" view in PhpStorm instead of in a new terminal, untick the Execute in terminal box

    1. Repeat this process for the queue worker php artisan queue:listen command

    2. That's it! Now, every time you open your project these tasks will automatically be run in the background. Minimize the Run tab and get back to work!