Digging Deeper
Artisan Console
Introduction
Artisan is the command line interface included with Laravel. In Laravel PHP, it's a command line interface to the framework. In Laravel Bash, the whole framework was a command line interface all along.
./sail artisan list
Running the Application
./artisan dev
composer run dev starts the server, a queue worker, Pail and Vite together, using the concurrently npm package. ./artisan dev does the same with &:
server │ INFO Server running on [http://0.0.0.0:8000].
queue │ INFO Processing jobs from the [default] queue with 4 worker(s).
events │ INFO Listening for events (PID 15). Send one with: kill -USR1 15
schedule │ INFO Running scheduled tasks every minute.
log │ [2026-12-05 00:12:12] local.INFO: Emailed the customer: order #5 has shipped
Each one is a real ./artisan process, started in the background with its output sent through a process substitution that adds the coloured prefix:
"$@" > >(dev::prefix "$name" "$colour") 2>&1 3>&- &
DEV_PROCESSES[$!]=$name
Because the prefixer is a process substitution rather than the end of a pipe, $! is the PID of the command itself. Then wait -n waits for whichever finishes first and, like concurrently --kill-others, stops the rest.
It's the container's default command, so ./sail up -d runs it.
Tinker
Tinker is an interactive Bash with the framework loaded:
./sail artisan tinker
Laravel Bash Tinker. Bash 5.2.15. Try: Post::all | take 3 | table
> Post::all | where status = published | only id title votes | take 3 | table
id title votes
1 Introducing Laravel Bash 342
2 Why every request gets its own process 128
3 Eloquent is a pipeline 256
It's bash --rcfile with an rc file that sources bootstrap/app.sh, then switches strict mode off, because in a REPL a typo shouldn't end the session. To run one line and exit:
./sail artisan tinker --execute='Post::all | count'
Writing Commands
A command is a function called artisan:: followed by the command name, with the colons swapped for underscores. Artisan finds it with declare -F:
artisan::podcasts_publish() {
local id=${1:?Usage: ./artisan podcasts:publish <id>}
dispatch ProcessPodcast "$id"
artisan::info "Podcast $id queued."
}
./sail artisan podcasts:publish 42
Output helpers
| Function | Prints |
|---|---|
artisan::info "Done." | INFO Done. on a cyan background |
artisan::error "Oops." | ERROR Oops. on a red background, to stderr |
artisan::line "Database" "sqlite" | Database ................ sqlite |
Generating Files
./sail artisan make:controller UserController
./sail artisan make:model Comment
./sail artisan make:job SendNewsletter
./sail artisan make:seeder UserSeeder
./sail artisan make:request StorePostRequest
The stubs are heredocs. make:model works out the table name with sed -E 's/([a-z0-9])([A-Z])/\1_\2/g' and ${table,,}, then adds an s. It does not know about irregular plurals.
Available Commands
| Command | Description |
|---|---|
about | Basic information about your application |
dev | Run the server, queue, events, scheduler and log together |
serve | Serve the application with socat |
tinker | Interact with your application |
inspire | Display an inspiring quote |
route:list | List all registered routes |
migrate | Run the migrations, --seed to seed |
migrate:fresh | Drop all tables and migrate again |
queue:work | Process jobs, --workers=N |
queue:failed / queue:retry | List or retry failed jobs |
horizon | Show the workers and job counts |
event:listen | Listen for events |
schedule:run / schedule:work / schedule:list | The scheduler |
test | shellcheck, then bats |
Some of them can be run from the browser on the Artisan example.