What is Artisan?
Artisan is the command-line interface (CLI) tool bundled with Laravel. It lives at the project root as theartisan script and provides many commands that streamline development and operations.
Use the list command to see every available command:
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.Creating custom commands
Generating a command
Usemake:command to scaffold a new command class:
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
Useargument() 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.
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.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 inroutes/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.
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.
artisan method, which automatically prefixes php artisan for you.
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).
blue, purple, pink, orange, green, and yellow. You can also pass a custom hex color to the color method.
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.