If you’re like most Laravel developers, you probably use the same handful of Artisan commands every day. php artisan migrate, php artisan make:controller, php artisan serve – we all know these by heart. But did you know Laravel ships with dozens of incredibly useful commands that most developers never discover?
I’ve been working with Laravel for years, and I’m constantly amazed by the hidden gems tucked away in Artisan. These aren’t just cool tricks — they’re productivity boosters that can save you hours of debugging time and make your development workflow smoother than ever.
Today, I want to share 15 lesser-known Artisan commands that have become indispensable in my daily development routine. Trust me, once you start using these, you’ll wonder how you ever lived without them.
1. Get Inside Your Models with model:show
Ever found yourself digging through model files trying to understand relationships and properties? This command is a game-changer:
php artisan model:show User
This little beauty shows you everything about your Eloquent model — relationships, attributes, observers, traits, and more. It’s like having X-ray vision for your models. I use this constantly when working on projects I haven’t touched in a while, or when diving into someone else’s codebase.
The output is beautifully formatted and tells you exactly what’s going on with your model without having to piece together information from multiple files.
2. Backup Your Database Schema Instantly
Here’s something that should be part of every developer’s workflow:
php artisan schema:dump
This command creates a snapshot of your current database schema and saves it to a file. It’s incredibly useful for several reasons:
- Team Collaboration: Share your exact database structure with teammates
- Deployment Safety: Have a backup before making schema changes
- Documentation: Keep a record of how your database has evolved
3. Inspect Any Table Structure
Sometimes you need to quickly check a table’s structure without opening your database client:
php artisan db:table users
This shows you columns, indexes, foreign keys — everything about a specific table. It’s perfect for those moments when you’re writing a migration and need to double-check the current structure.
4. See All Your Events at a Glance
Laravel’s event system can get complex quickly. This command helps you stay organized:
php artisan event:list
You’ll see every registered event and its listeners. This is invaluable for debugging event-driven applications and understanding the flow of your application’s business logic.
5. Export Routes as JSON
Need to document your API or share route information with your frontend team?
php artisan route:list --json
6. Secure Your Environment Files
Here’s a security feature many developers don’t know exists:
php artisan env:encrypt
This encrypts your .env file, making it safe to store in version control or share with team members. The encrypted file can't be read without the decryption key, adding an extra layer of security to your sensitive configuration data.
7. Decrypt Environment Files Safely
The companion to encryption:
php artisan env:decrypt
When you need to decrypt that encrypted environment file, this command handles it smoothly. It’s perfect for deployment scripts or when team members need access to configuration data.
8. Modern Log Monitoring with Pail
Forget about tail -f storage/logs/laravel.log:
php artisan pail
9. Never Miss a Scheduled Task Again
Want to see what tasks are scheduled and when they’ll run next?
php artisan schedule:list
This shows you all scheduled tasks with their descriptions, frequency, and next run times. It’s essential for maintaining complex applications with multiple scheduled jobs.
10. Test Your Scheduled Tasks
Here’s something that will save you from those “why didn’t my task run?” moments:
php artisan schedule:test
You can test your scheduled tasks without waiting for them to run naturally. This is crucial for ensuring your cron jobs work correctly before deploying to production.
11. Clean Up Redis Cache Tags
If you’re using Redis for caching with tags (and you should be):
php artisan cache:prune-stale-tags
This cleans up unused cache tags, keeping your Redis instance lean and performant. Cache tag cleanup is often overlooked, but it’s crucial for long-running applications.
12. Monitor Your Queue Sizes
Keep an eye on your queue performance:
php artisan queue:monitor default,emails,reports
This monitors the size of specified queues and can alert you when they get backed up. It’s perfect for maintaining healthy queue performance in production environments.
13. Peek Into Your Configuration
Instead of opening config files to check values:
php artisan config:show database
php artisan config:show database.default
This shows you configuration values quickly and clearly. You can view entire config files or specific keys. It’s particularly useful when debugging configuration issues or when working in different environments.
14. Customize Artisan’s Code Generation
Want to modify how Laravel generates controllers, models, and other files?
php artisan stub:publish
This publishes Laravel’s default stubs to your application, allowing you to customize exactly how Artisan generates code. You can add your own boilerplate, modify class structures, or include custom comments.
15. Set Up API Routes Quickly
Need to add API functionality to an existing Laravel application?
php artisan install:api
Conclusion
These 15 hidden Laravel Artisan commands aren’t just neat tricks — they’re productivity boosters that can transform how you develop with Laravel. From model:show giving you instant model insights to schema:dump streamlining your deployment process, each command solves real problems you face every day.
The beauty of these tools lies in their simplicity. Instead of digging through multiple files to understand your application’s structure, you can get comprehensive information with a single command. Instead of manually monitoring logs or checking queue sizes, you have dedicated tools that do the heavy lifting for you.
If you found this helpful, feel free to share or drop a comment. Happy coding with Laravel! 🧱✨
Free resources for this topic
Code snippets and fixes for this topic
Get one practical tip every week
New tutorials, fixes and free cheat sheets from DEV Talk, straight to your inbox. No spam, unsubscribe in one click.
Free download: Laravel interview questions (PDF)
Have a question about this post?
Ask the community: other developers and the author can answer.
Get notified about new articles
One click, no email needed. Turn it off anytime with the bell at the top.
Get new articles on your iPhone
Add DEV Talk to your Home Screen, open it, then tap the bell.
Enjoying the content?
If this article helped you, you can support the author with a coffee. It keeps new posts coming.
Comments 0
No comments yet
Be the first to share your thoughts.