laravel-architecture

Enforce Laravel architectural patterns including Service classes, DTOs, and SOLID principles.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/sasabajic/laravel-best-practice-skills --skill laravel-architecture-sasabajic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-architecture
Source: https://github.com/sasabajic/laravel-best-practice-skills/tree/main/laravel-architecture
Command: npx skills add https://github.com/sasabajic/laravel-best-practice-skills --skill laravel-architecture-sasabajic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides clear guidelines and code examples for implementing robust architectural patterns and design principles in Laravel applications, leading to more maintainable, scalable, and organized codebases.

Core Features & Use Cases

  • Service Layer: Encapsulate complex business logic outside of controllers.
  • Action Classes: Define single-purpose, reusable operations.
  • DTOs: Ensure structured and immutable data transfer.
  • Repository Pattern: Abstract data access logic when necessary.
  • Event-Driven Architecture: Decouple side effects using Events and Listeners.
  • SOLID Principles: Apply fundamental object-oriented design principles.
  • Use Case: When developing a new feature that involves creating a user, updating their profile, and sending a welcome email, this Skill guides you to use a UserService to handle the multi-step logic, a CreateUserData DTO for input, and an OrderPlaced event with a listener to send the email asynchronously.

Quick Start

Implement the Service Layer pattern by creating a UserService class to handle user creation and updates.

Frequently Asked Questions about laravel-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure complex business logic in Laravel outside of controllers?

To structure complex business logic in Laravel, use Service classes to encapsulate multi-step operations outside controllers. This keeps controllers thin and groups related domain operations together for better maintainability.

When should I use DTOs in my Laravel application?

Use Data Transfer Objects (DTOs) in Laravel when you need to ensure structured and immutable data transfer across application layers. DTOs provide type-safe input handling and prevent unexpected data mutations during business logic execution.

What is the best way to decouple side effects like sending emails in Laravel?

The best way to decouple side effects in Laravel is using event-driven architecture. By dispatching Events and defining Listeners, you can handle asynchronous tasks like sending welcome emails separately from core business logic.

When do I need the Repository pattern in Laravel?

You need the Repository pattern in Laravel when you want to abstract data access logic away from your controllers and services. This is particularly useful for maintaining scalable codebases when dealing with complex database queries.

Can I use Action classes for single-purpose operations in Laravel?

Yes, you can use Action classes in Laravel to define single-purpose, reusable operations. This architectural pattern isolates specific tasks, complementing the Service layer by keeping individual business actions highly focused and modular.