<p>I recently switched to <a href="https://laravel.com/docs/9.x/valet">Laravel Valet</a> instead of <a href="https://laravel.com/docs/9.x/sail">Laravel Sail</a>. 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 <a href="https://www.jetbrains.com/help/phpstorm/settings-tools-startup-tasks.html">startup tasks</a> which work great for this use case.</p>
<ol>
<li>In PhpStorm config, head to <strong>Tools > Startup Tasks</strong></li>
<li>Add a new configuration and select <strong>Shell Script</strong></li>
</ol>
<p><img src="https://images.ctfassets.net/9b1r03jrrwqy/2lz2iL9Q4pTgewR0pzIRzP/e7a1a7286958b96b07d7596ea3231cc0/CleanShot_2022-10-06_at_10.22.00_2x.png" alt="CleanShot 2022-10-06 at 10.22.00@2x" /></p>
<ol start="3">
<li>Give the run configuration a name (e.g. "Laravel Scheduler")</li>
<li>Select <strong>Script text</strong> and enter the artisan command (e.g. <code>php artisan schedule:work</code>)</li>
<li>If you want these tasks to appear in the "Run" view in PhpStorm instead of in a new terminal, untick the <strong>Execute in terminal</strong> box</li>
</ol>
<p><img src="https://images.ctfassets.net/9b1r03jrrwqy/1Lxk39FCG42z9kM9HKhHNA/9e3d4d1c1c5751b93580b361639d0315/CleanShot_2022-10-06_at_10.22.24_2x.png" alt="CleanShot 2022-10-06 at 10.22.24@2x" /></p>
<ol start="6">
<li>Repeat this process for the queue worker <code>php artisan queue:listen</code> command</li>
<li>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!</li>
</ol>
<p><img src="https://images.ctfassets.net/9b1r03jrrwqy/5kDMfxguRYcc3dt4cMxtq3/c0842e7f99bbdcc602f4611374e34178/CleanShot_2022-10-06_at_10.24.13_2x.png" alt="CleanShot 2022-10-06 at 10.24.13@2x" /></p>