PHPackages                             shahghasiadil/laravel-clean-architecture-ddd-cqrs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. shahghasiadil/laravel-clean-architecture-ddd-cqrs

ActiveProject[Framework](/categories/framework)

shahghasiadil/laravel-clean-architecture-ddd-cqrs
=================================================

Explore Domain-Driven Design and CQRS in Laravel with this clean and scalable architecture template, ideal for complex applications seeking maintainability and clarity.

v1.0.3(1y ago)1134828[3 issues](https://github.com/shahghasiadil/laravel-clean-architecture-ddd-cqrs/issues)MITPHPPHP ^8.2CI passing

Since Jun 13Pushed 10mo ago5 watchersCompare

[ Source](https://github.com/shahghasiadil/laravel-clean-architecture-ddd-cqrs)[ Packagist](https://packagist.org/packages/shahghasiadil/laravel-clean-architecture-ddd-cqrs)[ RSS](/packages/shahghasiadil-laravel-clean-architecture-ddd-cqrs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (13)Versions (7)Used By (0)

Laravel Clean Architecture, DDD &amp; CQRS Project
==================================================

[](#laravel-clean-architecture-ddd--cqrs-project)

This Laravel project applies the principles of Clean Architecture, Domain-Driven Design (DDD), and Command Query Responsibility Segregation (CQRS) to create a robust, scalable, and maintainable web application. It is designed for developers who aim to build complex systems with a clear separation of concerns and a strong alignment between the business domain and technology.

Table of Contents
-----------------

[](#table-of-contents)

- [Key Concepts](#key-concepts)
- [Who is this project for?](#who-is-this-project-for)
- [When to Use This Project](#when-to-use-this-project)
- [Why Choose This Project Over Others?](#why-choose-this-project-over-others)
- [Prerequisites](#prerequisites)
- [Project Structure](#project-structure)
- [Contributing](#contributing)

Key Concepts
------------

[](#key-concepts)

- **Clean Architecture**: Ensures independence from UI, databases, frameworks, and external agencies. The dependency rule is central, promoting the inversion of control.
- **Domain-Driven Design (DDD)**: Focuses on complex domain logic, placing the primary project emphasis on the core domain and domain logic.
- **Command Query Responsibility Segregation (CQRS)**: Separates read and write operations, improving performance, scalability, and maintainability.

Who is this project for?
------------------------

[](#who-is-this-project-for)

This project is designed for developers and teams looking to leverage advanced architectural patterns in building complex business applications using Laravel. It is particularly suited for:

- **Enterprise Applications**: Where business rules and processes are complex, necessitating a clear separation between core logic and infrastructure.
- **Scalable Systems**: Where scalability and flexibility are crucial, enabling the system to evolve rapidly with changing business requirements.

When to Use This Project
------------------------

[](#when-to-use-this-project)

- **Building New Applications**: Ideal for initiating projects with a focus on long-term maintainability and adherence to sophisticated architectural patterns.
- **Refactoring Existing Applications**: Beneficial for restructuring a cluttered Laravel project into a more manageable and performant architecture.
- **Learning Best Practices**: Excellent for educational purposes to understand and implement high-level software architecture within a Laravel setting.

Why Choose This Project Over Others?
------------------------------------

[](#why-choose-this-project-over-others)

- **Advanced Clean Architecture**: Compared to traditional MVC or other Laravel projects, this framework integrates Clean Architecture principles more rigorously, promoting a high degree of independence between the domain logic, UI, and database.
- **Optimized for Laravel 11 &amp; 12**: Utilizes the latest features of Laravel 11 &amp; 12, offering a more advanced toolkit for dependency injection, queue management, and real-time event handling, which are essential for modern web applications.
- **Enhanced DDD Implementation**: Provides a deeper implementation of Domain-Driven Design than typical repositories, focusing on complex domain logic and ensuring that business rules are encapsulated within domain entities.
- **CQRS-Ready**: Includes a built-in structure for Command Query Responsibility Segregation, optimizing read and write operations for better performance and scalability compared to conventional Laravel architectures.
- **Service Layer Alternative**: Alongside CQRS, the project also supports a robust Service Layer architecture, providing an alternative approach for those preferring a more traditional but equally structured pattern for handling business logic and application services.

Prerequisites
-------------

[](#prerequisites)

Before you begin, ensure you have met the following requirements:

- PHP \[8.2, 8.3, 8.4\]
- Composer
- Laravel \[11, 12\]
- Any other server requirements or dependencies needed to run Laravel.

Here are the steps to get your development environment running:

1. Create Project directly via composer: ```
     composer create-project shahghasiadil/laravel-clean-architecture-ddd-cqrs my-app
    ```
2. Clone the repository: ```
    git clone https://github.com/shahghasiadil/laravel-clean-architecture-ddd-cqrs.git
    ```

Project Structure
-----------------

[](#project-structure)

The project follows a modular architecture based on Clean Architecture principles, separating concerns into distinct layers. Below is the directory structure and a detailed description of each layer's responsibility.

```
src/
├── Application/
│ ├── Bus/
│ ├── Providers/
│ └── User/
│ ├──── CommandHandlers/
│ ├──── Commands/
│ ├──── Contracts/
│ ├──── Data/
│ ├──── Queries/
│ └──── Services/
├── Domain/
│ ├── Providers/
│ ├── Common/
│ ├──── Enums/
│ ├──── Traits/
│ └── User/
│ ├──── Enums/
│ ├──── Entities/
│ ├──── Events/
│ ├──── Exceptions/
│ ├──── Observers/
│ ├──── Policies/
│ └──── Repositories/
├── Infrastructure/
│ ├── Providers/
│ └── User/
│ ├──── Jobs/
│ ├──── Notifications/
│ └──── Persistence/
│ └──────── Repositories/
├── Presentation/
│ └── UserManagement/
│ ├──── Controllers/
│ ├──── Middlewares/
│ ├──── Requests/
│ ├──── Resources/
│ └──── routes/
│ └── Controller.php
└── Shared/
├──── Contracts/
├──── Enums/
└──── Traits/

```

### Description of Layers

[](#description-of-layers)

- **Application**: Manages the application logic and orchestrates the flow of data between the domain and presentation layers. This layer includes:

    - `Bus`: Responsible for dispatching commands and queries to the appropriate handlers.
    - `Providers`: Service providers specific to the application layer, registering application-specific services and dependencies.
    - `User`: Contains all user-related business logic, divided into:
        - `CommandHandlers`: Handles commands related to user actions.
        - `Commands`: CQRS commands for user-related operations.
        - `Contracts`: Interface definitions for services and repositories dealing with user data.
        - `Data`: Data transfer objects (DTOs) that carry data between processes we are using Spatie Laravel Data Package.
        - `Queries`: CQRS queries for retrieving user data.
        - `Services`: Services that execute business logic and use cases related to users.
- **Domain**: The heart of the business logic, defining entities, value objects, and domain events.

    - `Providers`: Domain-level service providers that bind interfaces to implementations within the domain scope.
    - `Common`: Shared utilities and components that span across multiple domains:
        - `Enums`: Cross-domain enumerations defining shared constants and states.
        - `Traits`: Reusable traits that provide common functionality across various domains.
    - `User`: Domain logic and entities specific to user management, including:
        - `Entities`: Domain models representing users.
        - `Enums`: User-specific enumerations that define states or types relevant to user management.
        - `Events`: Events that are domain-specific and might trigger domain actions.
        - `Exceptions`: Custom exceptions for domain-specific error handling.
        - `Observers`: Observers for watching changes in domain entities.
        - `Policies`: Security policies related to user entities.
        - `Repositories`: Interfaces for user repository implementations.
- **Infrastructure**: Implements the interfaces defined by the domain layer, dealing with data persistence and external systems.

    - `Providers`: Infrastructure-level service providers that register infrastructure-specific services and dependencies.
    - `User`: Infrastructure logic specific to user management, including:
        - `Jobs`: Background jobs for asynchronous user tasks.
        - `Notifications`: Notification services to handle alerts and communications.
        - `Persistence`: Persistence mechanisms for user data, including:
            - `Repositories`: Concrete implementations of user repository interfaces.
- **Presentation**: Manages the delivery mechanisms, dealing with how the application is presented to the end user (APIs, web UI, etc.).

    - `UserManagement`: Presentation logic specifically for managing users, including:
        - `Controllers`: Controllers to handle incoming API requests and deliver appropriate responses.
        - `Middlewares`: Middleware to handle request filtering and pre/post processing.
        - `Requests`: Form requests for validating user-related data.
        - `Resources`: Resources and transformers that format domain data into user-friendly formats.
        - `routes`: Routing configurations that direct incoming requests to the appropriate controllers.
- **Shared**: Contains elements that are used across multiple layers, providing cross-cutting functionality.

    - `Contracts`: Shared interface definitions that might be used by many components.
    - `Enums`: Enumerations that provide a set of constants for use throughout the application.
    - `Traits`: Reusable traits that provide utility functions or methods to multiple classes.

This architecture not only segregates the responsibilities into clear, well-defined areas but also promotes a high degree of modularity and replaceability of components.

Contributing
------------

[](#contributing)

Contributions are welcome! Please fork the repository and submit pull requests to contribute.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance49

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~66 days

Total

5

Last Release

434d ago

Major Versions

v1.0.2 → 12.x-dev2025-03-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a0a3bb25b5438613463e20699f30cc02e24a0e57e7d171208e3d19bd6bf7b4a?d=identicon)[shahghasiadil](/maintainers/shahghasiadil)

---

Top Contributors

[![shahghasiadil](https://avatars.githubusercontent.com/u/64509320?v=4)](https://github.com/shahghasiadil "shahghasiadil (288 commits)")[![takielias](https://avatars.githubusercontent.com/u/38932580?v=4)](https://github.com/takielias "takielias (1 commits)")

---

Tags

clean-architecturecqrscqrs-patterndddddd-architectureddd-patternsdomain-driven-designlaravellaravel-11-clean-architecturelaravel-11-clean-architecture-ddd-cqrslaravel-11-cqrslaravel-11-ddd-cqrslaravel-clean-architecturelaravel-clean-architecure-ddd-cqrslaravel-cqrslaravel-ddd-cqrslaravel11phpphp-clean-architecturelaravellaravel-cqrslaravel-clean-architecture-ddd-cqrslaravel-clean-architecturelaravel-clean-architecture-dddlaravel-clean-architecture-cqrs

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/shahghasiadil-laravel-clean-architecture-ddd-cqrs/health.svg)

```
[![Health](https://phpackages.com/badges/shahghasiadil-laravel-clean-architecture-ddd-cqrs/health.svg)](https://phpackages.com/packages/shahghasiadil-laravel-clean-architecture-ddd-cqrs)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[krayin/laravel-crm

Krayin CRM

22.0k32.8k1](/packages/krayin-laravel-crm)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
