Basic Commands

Updated on Jul 11, 2024

Earlier in this tutorial, we mentioned that Artisan is the CLI for Laravel. While Laravel uses another command line utility in the form of Composer, Artisan is used to manage Laravel itself, not its dependencies. It is important not to confuse the two despite both being command-line utilities. With that said, though, let's look at some basic commands for Artisan and what they do. But how do we find out what commands are available to us? The developers of Artisan have been awesome enough to include a list command, which does exactly what it says: it lists all available Artisan commands. The command itself is this.

php artisan list

The screenshot above shows just the top of the list. There are many more beyond those. Now, let's check out a few of the more baseline commands.

  • php artisan docs - Access Laravel's documentation;
  • php artisan env - Displays information about your project's environment, such as if it is local or not;
  • php artisan help - When followed by the name of another command, this one will show you detailed information about what the command does and its uses;
  • php artisan serve - Serve an application to the PHP development server. In other words, launch your application and its server in development mode;
  • php artisan cache:clear - Clear your application's cache;
  • php artisan db:show - Shows information about your application's database;
  • php artisan --version - Shows the version of your Laravel application.

Using these commands, you can manage your application and view its information on a more basic level. You might have noticed that the top of the list also contains an Options section. These options can be appended to each command, and they will alter the way it functions. For instance, writing a -h after a command will display the help section for that command instead of running it. Not only that, but you will also see all the options that specific command can use. Like this, for example.

We ran the php artisan serve -h command, which did not start our development server. Instead, it showed us an explanation of what the command does and also gave us all the options it can use. These options are incredibly useful when you want to customize the way a command works.

Next, we will discuss some commands that allow you to configure your application directly from the CLI.

On this page...