Skip to content

Vendor-neutral, engineer-written explanations. Clear definitions first, then practical steps with real examples — no fluff.

What is Artisan in Laravel?

SB
Written by StageBit Engineering Team
Updated January 2026 2 min readVerified by engineers

Artisan is Laravel’s built-in command-line interface (CLI), designed to automate repetitive tasks, manage databases, generate boilerplate code, and interact with your application efficiently. It exists as a script at the root of your project (php artisan), empowering developers to work faster and more systematically.

Why Artisan Matters

Without Artisan, tasks like creating controllers, migrations, or scheduling jobs would require manual coding. Artisan saves time, reduces errors, and improves maintainability. Modern Laravel versions (v11 and v12) also include interactive forms and prompts, enhancing usability for developers.

Modern Key Features

  • Code Generation: Scaffold models, controllers, migrations, factories, and seeders with commands like php artisan make:model Post -mfs.
  • Database Management: Run php artisan migrate for schema changes and php artisan db:seed for populating data.
  • REPL (Tinker): Open an interactive shell with php artisan tinker to experiment with Eloquent models, jobs, and events.
  • Laravel Prompts (v11/v12): Modern, user-friendly forms with validation, placeholders, and multi-select options for gathering input interactively.
  • Task Scheduling: Use php artisan schedule:work or schedule:run to handle cron jobs entirely within Laravel.
  • Closure-Based Commands: Define quick commands directly in routes/console.php without creating full classes.
  • Stub Customization: Customize the code templates generated by Artisan to match your project standards.

Example 1: Interactive User Input (Laravel Prompts)

use function Laravel\Prompts\text;
use function Laravel\Prompts\password;
use function Laravel\Prompts\confirm;

public function handle()
{
    $name = text('What is your name?', required: true);
    $pass = password('Enter your API secret');

    if (confirm('Do you want to run the migration?')) {
        $this->info("Proceeding, $name...");
    }
}

Example 2: Closure-Based Command

use Illuminate\Support\Facades\Artisan;

Artisan::command('report:generate {type}', function (string $type) {
    $this->info("Generating the {$type} report...");
})->purpose('Generate a daily business report');

Example 3: Custom Command with Dependency Injection

namespace App\Console\Commands;

use App\Models\User;
use App\Support\DripEmailer;
use Illuminate\Console\Command;

class SendEmails extends Command
{
    protected $signature = 'mail:send {user}';
    protected $description = 'Send a marketing email to a user';

    public function handle(DripEmailer $drip)
    {
        $drip->send(User::find($this->argument('user')));
        $this->info('Email sent successfully!');
    }
}

Example 4: Stub Customization

To modify the templates used for generating controllers, models, or migrations:

php artisan stub:publish

All default stubs are copied to /stubs so you can edit them. New files generated with make:controller, make:model, etc., will now use your customized templates.

Essential Artisan Command Cheat Sheet

CommandDescription
php artisan listView all commands available in the application
php artisan aboutShow a detailed overview of your environment and dependencies
php artisan make:…Create controllers, models, events, mail classes, and more
php artisan migrateRun pending database migrations
php artisan db:seedPopulate database with seed data
php artisan route:listView all registered routes and their controllers
php artisan optimizeCache routes, config, and views for production

Conclusion: Artisan is no longer just a basic CLI; it’s a fully featured developer toolkit in Laravel 11 and 12. With modern features like Laravel Prompts, closure commands, and stub customization, developers can automate, test, and scaffold entire applications with efficiency and elegance.

Was this answer helpful?

Your feedback helps us improve our answers.

Still need help?

Talk to our Laravel experts

We've handled GDPR/CCPA compliance for dozens of EU & US Laravel.

Talk to Laravel Experts

Tell us more about your brand!

Rohit Kundale, Our VP of Sales and Marketing is ready to meet with your team.