Artisan is Laravel's command-line tool. Run it from the project folder with php artisan <command>.
Generate files
php artisan make:model Post -mcr— model + migration, controller and resource methods in one gomake:controller,make:migration,make:request,make:middleware,make:seeder,make:mail,make:job
Everyday commands
php artisan list— every available commandphp artisan route:list— all routesphp artisan migrate— run migrationsphp artisan tinker— an interactive PHP shell with your app loaded, great for testing queriesphp artisan storage:link— make uploaded files publicphp artisan key:generate— setAPP_KEYin.env
Clearing caches
When a change does not appear, run php artisan optimize:clear. It clears the config, route, view and application caches.
Maintenance mode
php artisan down shows a "Service Unavailable" page to visitors while you update; php artisan up brings the site back.
Add --help to any command to see its options, e.g. php artisan make:model --help.
Example
Example — Generate a full set of files and test in Tinker
Bash
# Model + migration + resource controller
php artisan make:model Post -mcr
# INFO Model [app/Models/Post.php] created successfully.
# INFO Migration [database/migrations/..._create_posts_table.php] created successfully.
# INFO Controller [app/Http/Controllers/PostController.php] created successfully.
# Try Eloquent queries interactively
php artisan tinker
> App\Models\User::count()
= 3
> exit
# Something not updating? Clear all caches
php artisan optimize:clear
-mcr means -m (migration), -c (controller) and -r (resource methods). Tinker runs PHP code against your real database, so be careful with delete() there.