Mastering Artisan: 15 Commands Every Laravel Newbie Should Know
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.
1. Create a New Laravel Project
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.
2. Run the Development Server
Launch your application locally:
php artisan serve
Customize port:
php artisan serve --port=8080
3. Generate a Controller
Create controller files instantly:
php artisan make:controller PostController
Need API methods? Add --api:
php artisan make:controller PostController --api
4. Create a Model with Migration
Generate a model and its database migration together:
php artisan make:model Post -m
The -m flag creates a migration file in database/migrations.
5. Run 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
6. Create a Database Seeder
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
7. Generate a Middleware
Create custom request filters:
php artisan make:middleware AdminMiddleware
Register it in app/Http/Kernel.php.
8. List All Routes
View your application's route list:
php artisan route:list
Filter routes:
php artisan route:list --method=GET
9. Create a Job
For queueable tasks:
php artisan make:job ProcessPodcast
Dispatch jobs from controllers to handle time-consuming tasks asynchronously.
10. Clear Application Cache
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
11. Generate Authentication Scaffolding
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
12. Create a Custom Artisan Command
Build your own CLI tools:
php artisan make:command BackupDatabase
Edit the generated file in app/Console/Commands.
13. Tinker with Your App
Interactive PHP shell for debugging:
php artisan tinker
Try queries instantly:
>>> User::find(1)
>>> factory(App\User::class)->make()
14. Generate Notifications
Create notification classes:
php artisan make:notification InvoicePaid
Send via email, SMS (Nexmo/Vonage), Slack, etc.
15. Schedule Tasks
Edit the scheduler (runs via cron):
php artisan schedule:run
Define jobs in app/Console/Kernel.php:
$schedule->command('inspire')->hourly();
Bonus: Essential Shortcuts
Quick Model Creation
-aflag creates controller, migration, factory, and seeder:php artisan make:model Post -aEnvironment Management
Cache your config (production only):php artisan config:cacheStorage Link
Link public storage:php artisan storage:link
When Things Go Wrong
- Undefined variable errors?
php artisan view:clear - Route not found?
php artisan route:clear - Class not found?
composer dump-autoload
Conclusion
Master these 15 commands and you'll:
✅ Build features faster
✅ Debug efficiently
✅ Manage databases like a pro
✅ Automate repetitive tasks
Next Steps:
- Explore
php artisan listfor all available commands - Create custom commands for your project-specific tasks
- Learn command signatures and options with
php artisan help [command]
🚀 You're now an Artisan power user! What command will you try first? Drop it in the comments! 👇
Projects to explore next
Source-code projects from the KritiMyantra catalogue. Check each project's details before buying.
Flask Authentication System (Free Version) - Kritim Yantra
🛠 Features✔ Google & GitHub Authentication✔ User Registration & Login✔ Profile/Dashboard Access✔ Secure & Mi...
Flask Blog CMS with Admin Dashboard — Python Source Code
A Flask-based blogging website with a built-in admin dashboard. Manage articles, images, categories, tags and featured p...
Laravel 12 + ReactJS Starter Kit: Add Multi-Language Support (Arabic, English, Spanish) with Blog CRUD
🚀 Installation & Setup Download & Extract Get the ZIP from kritimyantra.com and extract it. Includes preconfigu...
Comments
No comments yet. Be the first to comment.
Sign in to join the discussion.