screenshot of VS Code workspace task configuration

VS Code and Laravel Tasks

Several of my recent projects are Laravel apps that use Horizon to manage the queue and run jobs.

However, I frequently forgot to run php artisan horizon when opening the project, and sometimes spent a bit of time trying to figure out why a job hadn’t run before remembering. 🤦

In addition—and this is a relatively minor annoyance—even when I do remember to start Horizon, sometimes I’d like to see the metrics dashboard showing how many jobs have run in the past few minutes.

Edit: I added npm run watch to help with Tailwind JIT mode.

Workspace Tasks

Enter VS Code’s Tasks feature. This can automatically start running tasks when a workspace is opened.

To get set up:

  1. Open the command palette (command-shift-P) and activate “Tasks: Manage Automatic Tasks in Folder”
  2. Activate “Allow Automatic Tasks in Folder”
  3. Open the command palette again and activate “Tasks: Open Workspace Tasks”
  4. Add the following to the workspace:

Now every time I open the workspace, assets are rebuilt as I modify them and Horizon and the scheduler run automatically.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.