Skip to main content

What is Artisan?

Artisan is the command-line interface bundled with Laravel. It lives at the project root as the artisan script and provides dozens of commands to help you build and maintain your application. List all available commands:
Get help for a specific command:
If you use Laravel Sail, replace php artisan with sail artisan. Commands run inside the Docker container.

Tinker (REPL)

Laravel Tinker is an interactive REPL that lets you interact with your application directly from the terminal—query Eloquent models, dispatch jobs, fire events, and more.
Once inside Tinker you can run any PHP code:
Tinker writes to your real database. Limit its use to local or staging environments, and be careful on production.

Writing commands

Generating a command

Use make:command to scaffold a new command class in app/Console/Commands:

Command structure

In Laravel 13, define the command signature and description with PHP attributes. The handle() method contains the logic:
You can also use the classic $signature and $description properties instead of attributes—both work in Laravel 13.
Keep commands thin. Delegate the actual work to service classes so your logic stays reusable and testable.

Exit codes

A command exits with 0 (success) by default. Return an integer from handle() to set a custom exit code:
Or call fail() to immediately terminate with exit code 1:

Closure commands

Define lightweight commands directly in routes/console.php without a full class:

Defining input

Arguments and options

Define arguments and options in the $signature string (or #[Signature] attribute):

Retrieving input

input() — typed accessors

The input() method lets you retrieve command arguments and options through the same typed accessors available on HTTP requests.
Pass a name directly to retrieve a specific value from either arguments or options:
While argument() and option() return strings, the typed accessors on input() convert values to the appropriate type. Use them for type-safe dates, numbers, enums, and similar values.

Interacting with the user

Output methods

Prompting for input

Progress bars

Display progress for long-running operations:
Manual control for more flexibility:

Practical example: data import command

1

Generate the command

2

Implement the command

3

Run the command

Scheduling commands

Register commands in routes/console.php to run them on a schedule. See the Task scheduling guide for details.

Testing commands

Use the artisan() testing helper to simulate running a command:

Common commands

Last modified on July 13, 2026