How to Run Laravel Artisan Commands in Visual Studio Code

Laravel ships with a command-line interface called Artisan Console. While building an application in Laravel, you can use this interface to run helpful commands. It allows you to create a controller, model, migrations, event, clear caches, and much more. If you look at the root directory of your Laravel project, you will see the artisan file which executes the Artisan commands.

In addition to the command-line interface, you can also run Artisan commands within your text editor like Sublime Text, Visual Studio Code. These 2 are the most popular editors among developers. I already wrote an article running Artisan commands in Sublime Text. In this quick tutorial, I show you how to run Artisan commands in Visual Studio Code.

Install Laravel Artisan Extension in Visual Studio Code

VSCode comes with tons of extensions that support your development workflow. Using extensions, one can achieve their stuff within the editor itself without going to another tool or somewhere else.

As an example to test REST APIs you can use Rest Client Extension in VSCode. With this extension, you can hit the REST API endpoints within the editor. You don’t need to install any other software like Postman.

Similarly, Laravel Artisan is an extension that helps you to run Laravel Artisan commands within Visual Studio Code.

Below are the steps to install the Laravel Artisan extension.

  • Open the VSCode and click on the Extension icon.
  • Type Laravel Artisan in the search field.
  • From the list, choose the extension developed by Ryan Naddy.
  • Click on Install.

Refer to the screenshot below.

install-laravel-artisan-extension

Run Laravel Artisan Extension in Visual Studio Code

Once you install the Laravel Artisan extension, you can skip using the command-line interface. All Artisan commands will be available inside the VSCode editor.

To run the Artisan commands, type ctrl+shift+p on Windows machines and cmd+shift+p on macOS. It will prompt you to a search field where you should type artisan which will then populate all available Artisan commands. Select any of the commands you wish to run and it will give you the expected output.

artisan-commands-vscode

Go ahead and explore it by selecting various commands. I hope it will add a bit of productivity to your work.

If you liked this article, then please subscribe to our YouTube Channel for video tutorials.

Leave a Reply

Your email address will not be published.