Artisan Commands

Complete reference for Laravel Artisan console commands.

Clear
auth
php artisan php artisan make:auth

Scaffold basic login and registration views and routes.

Deprecated in Laravel 8+. Use composer require laravel/breeze --dev && php artisan breeze:install instead. Historically created authentication scaffolding with views, routes, and controllers.

configuration
php artisan php artisan cache:clear

Flush all items from the cache store.

Removes all cached data from the configured cache driver (Redis, file, database). Use after deploying code that changes cached data. Safe to run in production.

configuration
php artisan php artisan cache:forget

Remove a specific item from the cache.

Removes a single cached item by its key. Useful for targeted cache invalidation without flushing everything. The key must match exactly what was used to store the item.

configuration
php artisan php artisan config:cache

Cache all configuration into a single file for faster loading.

Combines all config files into bootstrap/cache/config.php. Eliminates file scans for config values. Run after deploying new configuration. Does NOT read .env after caching — set values directly.

configuration
php artisan php artisan config:clear

Remove the cached configuration file.

Deletes bootstrap/cache/config.php. After clearing, config is read from individual files. Required after changing .env values in development. Config is re-cached on next request if config:cache has been run.

configuration
php artisan php artisan install:api

Install API route file and configure Sanctum for API authentication.

Creates routes/api.php, publishes Sanctum configuration and migrations, and adds API middleware. Essential for setting up a new API in a Laravel project.

configuration
php artisan php artisan key:generate

Generate a new random application encryption key.

Generates a 32-character random key and sets it in .env as APP_KEY. Used for encryption, hashing, and cookie signing. Run after initial installation or if the key is compromised.

configuration
php artisan php artisan route:cache

Create a cached routes file for faster route registration in production.

Serializes all routes into a single PHP file, bypassing file scanning. Dramatically speeds up route loading. MUST be cleared when adding/removing routes. Not compatible with Closure routes.

configuration
php artisan php artisan route:list

Display all registered routes with their methods, URIs, and associated controllers.

Shows all routes with HTTP method, URI, name, and action. --method filters by HTTP verb. --path filters by URI prefix. --name filters by route name. Essential for debugging routing issues.

configuration
php artisan php artisan storage:link

Create a symbolic link from public/storage to storage/app/public.

Creates a symlink so files stored in storage/app/public are accessible via the web. Required for serving user-uploaded files. The public directory is the web root.

configuration
php artisan php artisan view:cache

Pre-compile all Blade views for faster rendering.

Compiles all Blade templates into PHP and caches them. Eliminates runtime compilation overhead. Run after deploying new views. If a view is modified, clear and re-cache.

configuration
php artisan php artisan view:clear

Remove all compiled Blade view files.

Deletes all cached/compiled Blade views from storage/framework/views. Required after modifying Blade templates in production. Views are recompiled on next request.

database
php artisan php artisan cache:table

Create a migration for the database cache driver.

Generates a migration to create the cache table in your database. Required when using CACHE_DRIVER=database. The table stores cached items with expiration support.

database
php artisan php artisan db:monitor

Monitor database connections and alert when they are below a threshold.

Checks database connections and reports when available connections fall below the threshold. Useful for scheduling to proactively detect connection pool exhaustion.

database
php artisan php artisan db:seed

Run database seeders to populate the database with data.

Runs the run() method of all seeders called in DatabaseSeeder, or a specific seeder with --class. --force allows seeding in production. Seeders are idempotent when using firstOrCreate.

database
php artisan php artisan db:wipe

Drop all tables from the database.

Drops all tables in the database. Used internally by migrate:fresh. Useful when you want to manually drop and recreate tables. Use with caution — this destroys all data.

database
php artisan php artisan migrate

Run all pending database migrations to update the schema.

Executes the up() method of all migrations that haven't been run yet. --force is required in production. --pretend shows the SQL without executing it. Migrations track which have been run in the migrations table.

database
php artisan php artisan migrate:fresh

Drop all tables and re-run all migrations from scratch.

Drops all tables, then runs all migrations. --seed also runs the DatabaseSeeder. Useful during development. NEVER use in production. Only works with databases that support foreign key constraints.

database
php artisan php artisan migrate:rollback

Roll back the last batch of migrations.

Runs the down() method of the last batch of migrations. --step=N rolls back exactly N migrations. Without --step, it rolls back the entire last batch. Check migrate:status to see which batch you're on.

database
php artisan php artisan migrate:status

Display the status of all migrations showing which have been run.

Shows a table listing all migration files, their batch number, and whether they've been applied. Useful for debugging migration issues and seeing which migrations are pending.