DEV Community

Cover image for Getting Started with Laravel Artisan Commands
Rohit Dhiman
Rohit Dhiman

Posted on

Getting Started with Laravel Artisan Commands

If you’ve just started learning Laravel, you’ve probably heard about Artisan commands.
But what exactly are they? And why should you use them?

In this guide, we’ll walk through the basics of Artisan, some commonly used commands, and why they make Laravel development so much easier.


What is Artisan?

Artisan is Laravel’s built-in command-line interface (CLI).
It comes bundled with the framework and allows you to:

  • Generate code quickly (controllers, models, migrations, etc.)
  • Run database migrations
  • Start a development server
  • Clear caches and optimize your app
  • And much more...

Think of Artisan as your personal assistant that takes care of repetitive coding tasks so you can focus on building features.


Basic Artisan Commands You Should Know

Here are some of the most useful commands for beginners:

1. Check Available Commands

php artisan list
Enter fullscreen mode Exit fullscreen mode

This will display all the available Artisan commands in your project.


2. Check Laravel Version

php artisan --version
Enter fullscreen mode Exit fullscreen mode

Quick way to see which Laravel version your project is running on.


3. Create a Controller

php artisan make:controller UserController
Enter fullscreen mode Exit fullscreen mode

This generates a new UserController.php file inside the app/Http/Controllers directory.


4. Create a Model

php artisan make:model Post
Enter fullscreen mode Exit fullscreen mode

This creates a Post.php model inside the app/Models directory.


5. Run Migrations

php artisan migrate
Enter fullscreen mode Exit fullscreen mode

Applies all pending migrations to your database.


6. Rollback Migrations

php artisan migrate:rollback
Enter fullscreen mode Exit fullscreen mode

Undoes the last batch of migrations. Useful when testing database changes.


7. Start Local Development Server

php artisan serve
Enter fullscreen mode Exit fullscreen mode

Runs a local PHP server so you can test your app in the browser. By default, it’s available at:
👉 http://127.0.0.1:8000


Why Use Artisan?

  • Saves time – You don’t have to write boilerplate code manually.
  • Reduces errors – Commands follow Laravel’s conventions.
  • Boosts productivity – Quick shortcuts for everyday tasks.
  • Keeps project organized – Files are generated in the right structure.

Pro Tips for Beginners

  • Use php artisan help <command> to get details about any command. Example:
  php artisan help make:controller
Enter fullscreen mode Exit fullscreen mode
  • Explore Artisan daily. The more commands you try, the faster you’ll learn Laravel.

Final Thoughts

Artisan is one of the features that makes Laravel such a developer-friendly framework.
If you’re just getting started, make it a habit to run a few Artisan commands every day. You’ll quickly see how much time it saves and how it improves your workflow.

👉 What’s your favorite Artisan command so far? Share it in the comments!

Top comments (0)