What you can do after this lesson
You will be able to explore any Laravel project from the terminal and generate code with commands rather than copying files by hand. Artisan is the file named artisan in the project root. Run it with PHP from inside the project: php artisan ....
Discovering commands
php artisan listprints every command, grouped by a prefix called a namespace (make:, migrate:, route:, queue:, cache: and so on). The list depends on which packages are installed. To see only one group, name it:
php artisan list makeTo read the arguments and options of one command:
php artisan help migrateDescription:
Run the database migrations
Usage:
migrate [options]
Options:
--database[=DATABASE] The database connection to use
--force Force the operation to run when in production
--pretend Dump the SQL queries that would be run
--seed Indicates if the seed task should be re-run(Output shortened. Example captured on 2026-11 from Laravel 13.42.0.) Commands also accept -v, -vv and -vvv for more detail, -n to skip questions and --no-ansi to turn off colours, which is useful when saving output to a file.
Generators
The make: commands create files for you. Their value is correct placement: the right folder, namespace and base class. In this fresh 13.42.0 install php artisan list --raw includes make:controller, make:model, make:migration, make:request, make:policy, make:factory, make:seeder, make:middleware, make:job, make:event, make:listener, make:mail, make:resource, make:test and more. You will use most of them in this course. Most take flags; for example php artisan make:controller --help shows --resource, --api, --invokable, --model and --requests.
Inspecting the app
php artisan route:list
php artisan env
php artisan config:show app
php artisan about GET|HEAD / ............................................... routes/web.php:5
GET|HEAD storage/{path} storage.local › vendor/laravel/framework/src/Illum…
GET|HEAD up ...................... Illuminate\Foundation › HealthCheck
INFO The application environment is [local].route:list accepts --path, --method, --name, --json and --except-vendor to filter. about prints the Laravel and PHP versions, the environment, debug mode and which drivers are in use for cache, queue, session, mail and database.
Tinker
Tinker boots your app and runs PHP in it. Interactively you type php artisan tinker and then statements. For one-off checks, and for this course's examples, use --execute:
php artisan tinker --execute='echo config("app.name"), PHP_EOL, str("hello world")->title(), PHP_EOL;'Laravel
Hello WorldEverything your app can do is available: facades, models, helpers. Be careful, because tinker runs against your real configured database. Do not point it at production data casually.
Writing your own command
A custom command is a class. Generate it:
php artisan make:command ShopInfo --command=shop:infoIn Laravel 13 the generated class describes the command's name and description with PHP attributes (#[Signature(...)] and #[Description(...)]) above the class. Older tutorials declare $signature and $description properties instead; both are the same idea, so check which version a tutorial uses. Here is the finished command for Pagelane Books, with an option:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('shop:info {--upper : Print the name in capitals}')]
#[Description('Show the shop name from the configuration')]
class ShopInfo extends Command
{
public function handle(): int
{
$name = config('app.name');
$this->info($this->option('upper') ? strtoupper($name) : $name);
return self::SUCCESS;
}
}Run it:
php artisan shop:info
php artisan shop:info --upperLaravel
LARAVELIt prints "Laravel" because the app is not renamed yet; the next lesson changes that. The commands in app/Console/Commands are discovered automatically, so no registration is needed. The return value is the exit code: self::SUCCESS is 0, which shell scripts and schedulers read.
Common mistakes
- Running Artisan from the wrong folder. It must be run in the project root (the folder containing
artisan). - Hand-writing class files with a wrong namespace. Use
make:and edit the result. - Using tinker or destructive commands on production. Commands like
migrate:freshdrop all tables. Laravel asks for confirmation in production, but do not rely on it. - Copying an old tutorial's command signature. Your version's
php artisan make:commandoutput is the truth for your version.
Exercise
Add an option --greet to shop:info so that php artisan shop:info --greet prints Welcome to Laravel, where the name comes from config. Run it.
Show one possible answer
Change the signature to 'shop:info {--upper : Print the name in capitals} {--greet : Add a welcome message}' and the body to:
$name = config('app.name');
$text = $this->option('greet') ? "Welcome to {$name}" : $name;
$this->info($this->option('upper') ? strtoupper($text) : $text);
return self::SUCCESS;Then php artisan shop:info --greet prints Welcome to Laravel. Now set up the app's settings in configuration and the .env file.
Key points
- php artisan is the project's command line; php artisan list shows everything and php artisan help NAME explains one command.
- make:* commands generate classes in the right folder with the right namespace, saving typing and mistakes.
- route:list, about, env and config:show let you inspect the running app without opening files.
- tinker (and tinker --execute) runs PHP code inside the app, which is handy for trying ideas.
- make:command creates your own commands; in Laravel 13 the name and description are PHP attributes.