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.
Enter VS Code’s Tasks feature. This can automatically start running tasks when a workspace is opened.
To get set up:
- If you haven’t yet, go to File > Save Workspace As… and save a workspace config file to somewhere on your hard drive
- Open the command palette (command-shift-P) and activate “Tasks: Manage Automatic Tasks in Folder”
- Activate “Allow Automatic Tasks”
- Open the command palette again and activate “Workspaces: Open Workspace Configuration File”
- Add the following to the workspace config file:
Now every time I open the workspace, assets are rebuilt as I modify them and Horizon and the scheduler start running automatically.