Back to Blog

Laravel 12 New Artisan Commands: Enhancing Developer Productivity

Laravel 12 introduces powerful new Artisan commands that streamline development workflows, enhance debugging, and improve efficiency. This guide explores these new commands with practical examples, making it easier for Laravel developers to boost productivity. What is Artisan? Artisan is Laravel’s built-in command-line interface (CLI), providing a wide range of commands to automate tasks such as […]

Laravel 12 New Artisan Commands: Enhancing Developer Productivity

Laravel 12 introduces powerful new Artisan commands that streamline development workflows, enhance debugging, and improve efficiency. This guide explores these new commands with practical examples, making it easier for Laravel developers to boost productivity.

What is Artisan?

Artisan is Laravel's built-in command-line interface (CLI), providing a wide range of commands to automate tasks such as migrations, queue management, caching, and more. With Laravel 12, new Artisan commands further simplify application development.


New Artisan Commands in Laravel 12

1️⃣ php artisan model:show {model}

🔹 Description: Displays detailed information about a specific Eloquent model.

🔹 Usage:

php artisan model:show User

🔹 Output Example:

Model: App\Models\User
Table: users
Columns:
- id (integer, primary key)
- name (string)
- email (string, unique)
- created_at (timestamp)
- updated_at (timestamp)
Relationships:
- hasMany: App\Models\Post

🔹 Why It’s Useful?

  • Quickly review the structure of models.
  • See relationships and database mappings at a glance.

2️⃣ php artisan cache:clear --tags=tag1,tag2

🔹 Description: Clears cache for specific tags rather than wiping all cached data.

🔹 Usage:

php artisan cache:clear --tags=user_cache,settings

🔹 Why It’s Useful?

  • Improves performance by selectively clearing cache.
  • Avoids unnecessary cache invalidation.

3️⃣ php artisan queue:failed --since=1h

🔹 Description: Lists failed queue jobs within a specified timeframe.

🔹 Usage:

php artisan queue:failed --since=1h

🔹 Why It’s Useful?

  • Helps debug recent queue failures quickly.
  • Avoids scanning all failed jobs manually.

4️⃣ php artisan event:list --only=custom

🔹 Description: Lists only custom application events instead of all system and framework events.

🔹 Usage:

php artisan event:list --only=custom

🔹 Why It’s Useful?

  • Makes debugging easier by filtering unnecessary events.
  • Helps identify custom events efficiently.

5️⃣ php artisan db:monitor

🔹 Description: Continuously monitors database connections and queries in real-time.

🔹 Usage:

php artisan db:monitor

🔹 Why It’s Useful?

  • Helps optimize database queries.
  • Identifies slow queries in real time.

Bonus: Enhancements to Existing Commands

🔹 php artisan test --parallel → Runs test suites in parallel, speeding up execution.

🔹 php artisan migrate:status --detailed → Shows migration history with timestamps and statuses.


Conclusion

Laravel 12’s new Artisan commands significantly enhance developer productivity. From debugging queue failures to monitoring databases, these additions streamline workflows and optimize performance. If you're looking for custom Laravel development, let’s build something amazing together! 🚀