Artisan commands

Laravel Artisan Commands Cheat Sheet

Artisan Cheatsheet

🛠 General Artisan Commands

php artisan list                            # Show all available Artisan commands
php artisan help <command>                  # Get help for a specific command
php artisan tinker                          # Open Laravel's interactive console

🎭 Application Management

php artisan serve                           # Start a local development server
php artisan down                            # Put the application into maintenance mode
php artisan up                              # Bring the application out of maintenance mode

🚀 Database & Migrations

php artisan migrate                         # Run pending migrations
php artisan migrate:rollback                # Undo the last migration batch
php artisan migrate:reset                   # Roll back all migrations
php artisan db:seed                         # Seed database with test data
php artisan migrate:fresh --seed            # Refresh database and re-run seeders

⚙️ Model & Controller Management

php artisan make:model <ModelName>          # Create a new model
php artisan make:controller <ControllerName> # Create a new controller
php artisan make:model <ModelName> -mcr     # Create a model with migration, controller, and resource

🔐 Authentication & Authorization

php artisan make:middleware <MiddlewareName> # Generate a new middleware
php artisan make:policy <PolicyName>        # Generate a new policy

📜 Route & Cache Management

php artisan route:list                      # Show all registered routes
php artisan cache:clear                     # Clear application cache
php artisan config:clear                    # Clear configuration cache
php artisan route:cache                     # Cache the routes for better performance

🛠 Custom Commands

php artisan make:command <CommandName>      # Create a custom Artisan command

External resources

Artisan Console

artisan.page