Skip to main content

What is Artisan?

Artisan is the command-line interface (CLI) tool bundled with Laravel. It lives at the project root as the artisan script and provides many commands that streamline development and operations. Use the list command to see every available command:
Prefix any command with help to view its usage:
If you use Laravel Sail, replace php artisan with sail artisan. Commands run inside the Docker container.

Tinker

Laravel Tinker is a REPL environment that lets you interactively work with your entire application from the command line — Eloquent models, jobs, events, and more.
Once launched you can execute PHP code directly:
Tinker actually mutates data. Be very careful running it in production. It is well suited to verifying behavior or debugging in local and staging environments.

Creating custom commands

Generating a command

Use make:command to scaffold a new command class:
This generates app/Console/Commands/ImportProducts.php.

Command structure

A generated command class has three main elements: $signature, $description, and handle().
Laravel 13 also supports defining commands with PHP attributes.

Defining arguments and options

Declare the command name, arguments, and options together in $signature.

Reading arguments and options

Use argument() and option() inside handle() to read values.

input() — typed accessors

The input() method exposes the same typed accessors HTTP requests use, so you can read command arguments and options with proper types.
If you only want a specific value, pass its name directly (both arguments and options are searched):
argument() and option() return strings, whereas the typed accessors on input() convert to the appropriate type. This is convenient when you want type-safe handling of dates, numbers, enums, and similar values.

User interaction

Writing output

Several helpers are available for writing colored messages to the console.

Prompting the user

You can accept interactive input from the user.

Progress bars

Show progress clearly while processing large amounts of data.
For manual, finer-grained control:

Practical use cases

A data import command

A practical example of importing product data from a CSV file.
1

Generate the command

2

Implement the command

3

Run the command

A periodic maintenance command

An example of a maintenance command run on a schedule, such as deleting old data.

Combining with scheduled execution

You can schedule commands you write in routes/console.php. See Task scheduling for details.

Testing commands

Use Laravel’s testing tools to verify Artisan commands behave as expected.
Example assertion methods available through artisan():

The dev command

The dev Artisan command starts the multiple processes you need for local development inside a single terminal window. By default it concurrently runs the PHP development server, the queue worker, log monitoring via Pail, and Vite asset compilation.
Under the hood, it uses the concurrently npm package to manage processes. Each process is labeled and color-coded, making it easy to distinguish them in the terminal output. If any process fails, all the others are automatically stopped. The processes run by default are:
The vite process auto-detects the Node package manager you use (npm, pnpm, Yarn, or Bun) and invokes the appropriate command.

Customizing dev processes

You can customize the processes the dev command runs with the DevCommands class. Typically you register them inside the boot method of your application’s AppServiceProvider. The register method takes a command string and an optional process name.
When registering an Artisan command, use the artisan method, which automatically prefixes php artisan for you.
Similarly, the node method prefixes the detected package manager’s run command (for example, npm run), and nodeExec prefixes the package manager’s exec command (for example, npx).
Registering a process with the same name as a default process replaces that default. For example, you can customize the server process to use a different port:
You can also customize the color of the process label shown in the terminal. Available color methods are blue, purple, pink, orange, green, and yellow. You can also pass a custom hex color to the color method.
To list the registered dev processes without actually starting them, use the dev:list command.

Filtering dev processes

Use the only method to run only specific processes when the dev command is executed. Similarly, except excludes specific processes.
If you also use Horizon or Reverb during local development, registering them with DevCommands::artisan() lets you start everything with a single php artisan dev command.

Common commands at a glance

Last modified on August 2, 2026