Kritim Yantra
Apr 09, 2025
Laravel's Artisan CLI is your Swiss Army knife for development. These commands will supercharge your workflow whether you're building your first app or working on enterprise projects. Here are the 15 most essential commands every Laravel developer should memorize.
Start fresh with a clean installation:
laravel new project-name
Or with Composer:
composer create-project laravel/laravel project-name
Pro Tip: Add --jet
for Inertia/React/Vue scaffolding or --dev
for the latest dev version.
Launch your application locally:
php artisan serve
Customize port:
php artisan serve --port=8080
Create controller files instantly:
php artisan make:controller PostController
Need API methods? Add --api
:
php artisan make:controller PostController --api
Generate a model and its database migration together:
php artisan make:model Post -m
The -m
flag creates a migration file in database/migrations
.
Execute pending migrations:
php artisan migrate
Rollback the last batch:
php artisan migrate:rollback
Danger Zone: Completely reset your database (development only!):
php artisan migrate:fresh
Generate test data easily:
php artisan make:seeder PostsTableSeeder
Run all seeders:
php artisan db:seed
Or specific ones:
php artisan db:seed --class=PostsTableSeeder
Create custom request filters:
php artisan make:middleware AdminMiddleware
Register it in app/Http/Kernel.php
.
View your application's route list:
php artisan route:list
Filter routes:
php artisan route:list --method=GET
For queueable tasks:
php artisan make:job ProcessPodcast
Dispatch jobs from controllers to handle time-consuming tasks asynchronously.
Fix when things get weird:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear
Nuclear option (clears all caches):
php artisan optimize:clear
Laravel Breeze (recommended):
composer require laravel/breeze --dev
php artisan breeze:install
npm install && npm run dev
php artisan migrate
Laravel UI (legacy):
composer require laravel/ui
php artisan ui vue --auth
Build your own CLI tools:
php artisan make:command BackupDatabase
Edit the generated file in app/Console/Commands
.
Interactive PHP shell for debugging:
php artisan tinker
Try queries instantly:
>>> User::find(1)
>>> factory(App\User::class)->make()
Create notification classes:
php artisan make:notification InvoicePaid
Send via email, SMS (Nexmo/Vonage), Slack, etc.
Edit the scheduler (runs via cron):
php artisan schedule:run
Define jobs in app/Console/Kernel.php
:
$schedule->command('inspire')->hourly();
Quick Model Creation-a
flag creates controller, migration, factory, and seeder:
php artisan make:model Post -a
Environment Management
Cache your config (production only):
php artisan config:cache
Storage Link
Link public storage:
php artisan storage:link
php artisan view:clear
php artisan route:clear
composer dump-autoload
Master these 15 commands and you'll:
✅ Build features faster
✅ Debug efficiently
✅ Manage databases like a pro
✅ Automate repetitive tasks
Next Steps:
php artisan list
for all available commands php artisan help [command]
🚀 You're now an Artisan power user! What command will you try first? Drop it in the comments! 👇
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google