Open In App

Laravel | Artisan Console Introduction

Improve
Improve
Like Article
Like
Save
Share
Report

Laravel has its own Command Line interface called Artisan. Its like a Linux command line but the commands are helpful for building a Laravel application. With this command-line tool, we can make models, controllers, and can do data migrations and many more. First, we will have to change the directory in your command line console (i.e. cmd on windows or terminal on Linux/Mac) or any other CLI software, to the directory of your Laravel app.

All artisan commands: Then by writing ‘php artisan list’ in the console, we will be able to see all the artisan commands that can be used. We can also write ‘php artisan’ and press enter, to display all the available commands in the artisan console. With this command, we will be able to see a long list of commands that the php artisan supports.

  • Command:
    php artisan list

    or

    php artisan
  • Output:

To get help: If we want to know more about any command then we can write:

  • Command:
    php artisan help

    or

    php artisan help make:model
  • Output:

Version check: If we want to know the version of our Laravel app then we can write ‘-V‘ option.

  • Command:
    php artisan -V
  • Output:

Make commands: If these are not enough, then we can make our own command by using make:command. Know more of it by using the help command as described above in To get help section.

  • Command:
    php artisan make:controller

Console Environment: There is one console environment that the Artisan provides and that is tinker. The Tinker gives you an environment with the help of which the user can interact with the Laravel application and gives a simple way to access the data in the database.

  • Command:
    php artisan tinker
  • Output:

Reference: https://laravel.com/docs/6.x/artisan


Last Updated : 30 Nov, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads