How to Run Laravel Artisan Commands in Visual Studio Code

Laravel ships with a command-line interface called Artisan Console. While building a Laravel application, this interface is used to run helpful commands. It allows you to create a controller, model, migrations, events, resources, and much more through the command line. At the root directory of your Laravel project, you will see the artisan file which executes all available Artisan commands.

Apart from using a command-line interface, you can also run Artisan commands within text editors like Sublime Text, or 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.

VS Code comes with tons of extensions that support your development workflow. Using extensions, one can achieve their stuff within the editor itself.

As an example to test REST APIs, you can use Rest Client Extension in VSCode. With this extension, you will 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. Let’s install it.

Install Laravel Artisan Extension in Visual Studio Code

Below are the steps to install the Laravel Artisan extension.

  • Open the VSCode and click on the Extension icon on the left sidebar.
  • 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, the Artisan commands will be available inside the VS Code editor. You can now skip using the command-line interface.

To run the Artisan commands, type ctrl+shift+p on Windows machines and cmd+shift+p on macOS. You can also open it from View -> Command Palette.

It will prompt 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. Let me know your thoughts in the comment section below. Also, share if you are using some other extension for this purpose.

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. Required fields are marked *