Artisan CLI
5 min read Quiz at the end
Master Artisan commands for generating code, running migrations, clearing caches, and managing queues.
Artisan CLI Commands
php artisan serve # start dev server
php artisan make:controller UserController # create controller
php artisan make:model Post -m # model + migration
php artisan make:model Post -mcr # model+migration+controller+resource
php artisan make:middleware AuthCheck
php artisan make:request StoreUserRequest
php artisan make:seeder UserSeeder
php artisan make:factory UserFactory
php artisan make:job SendEmailJob
php artisan make:event UserRegistered
php artisan make:listener SendWelcomeEmail
# Migrations
php artisan migrate
php artisan migrate:rollback
php artisan migrate:fresh --seed # drop all + re-migrate + seed
# Cache
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan optimize # cache config+routes+views
Topic Quiz · 5 questions
Test your understanding before moving on
1. What does "php artisan make:model Post -m" do?
💡 The -m flag creates a database migration file alongside the model.
2. Which command runs all pending migrations?
💡 php artisan migrate applies all pending database migrations.
3. Which command clears all caches at once?
💡 optimize:clear clears config, route, view, and event caches.
4. How do you list all registered routes?
💡 php artisan route:list shows all routes with methods, URIs, and controllers.
5. Which flag generates a resource controller?
💡 php artisan make:controller PostController --resource generates all 7 RESTful methods.