DEV Community

Cover image for 5 Laravel Artisan commands I use every single day
Sandra Sakura
Sandra Sakura

Posted on AI-assisted

5 Laravel Artisan commands I use every single day

5 Laravel Artisan commands I use every single day

If you're a Laravel dev, these five are probably burned into your terminal history too:

  1. php artisan make:model Post -mfsc
    Model + migration + factory + seeder + controller, one command. No more typing five separate make: commands like it's 2015.

  2. php artisan tinker
    Need to test a query or poke at a relationship real quick? Tinker over spinning up a whole route, every time.

  3. php artisan route:list --path=api
    Debugging a 404 or checking if middleware actually applied? This shows you instantly, no guessing.

  4. php artisan queue:work --tries=3
    Can't run jobs without this. That --tries flag has saved me from silently-failed jobs more than once.

  5. php artisan optimize:clear
    Something "just not updating"? Config, cache, routes, views? This is step zero before real debugging even starts.

Drop your most-used Artisan command below β€” curious what I'm missing πŸ‘‡

Top comments (2)

Collapse
 
raknaos profile image
Raknaos

make:model -mfsc is the one I'd put first too β€” the failure mode without it is a half-scaffolded model that passes review and then breaks on the first seeder run. For tinker, I get more mileage out of a small non-interactive snippet than the shell when I'm testing one relationship, because it's reproducible and I can paste it into an issue.

One I'd add: php artisan db:show --counts when you inherit a database nobody documented. It tells you which tables are actually populated before you write a query against an empty one. Do you keep a project-specific Artisan command in your repos, or is needing one a sign the codebase has outgrown the framework defaults?

Collapse
 
csandra_ericson profile image
Sandra Sakura

Good addition β€” db:show --counts is a nice one, especially for that "inherited chaos" scenario where you don't want to trust the schema without checking what's actually populated.