PHPackages                             damianopetrungaro/clean-architecture - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. damianopetrungaro/clean-architecture

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

damianopetrungaro/clean-architecture
====================================

A package of utilities for build clean application in PHP

v0.4.0(8y ago)9433920[1 issues](https://github.com/damianopetrungaro/clean-architecture/issues)MITPHPPHP &gt;=7.1

Since Mar 9Pushed 8y ago7 watchersCompare

[ Source](https://github.com/damianopetrungaro/clean-architecture)[ Packagist](https://packagist.org/packages/damianopetrungaro/clean-architecture)[ RSS](/packages/damianopetrungaro-clean-architecture/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

clean-architecture
==================

[](#clean-architecture)

[![Code Climate](https://camo.githubusercontent.com/207137a8697bbee120ceb51d5ad5b0016231c552e2f9f48b9109760c056ae59b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f64616d69616e6f70657472756e6761726f2f636c65616e2d6172636869746563747572652f6261646765732f6770612e737667)](https://codeclimate.com/github/damianopetrungaro/clean-architecture)[![Build Status](https://camo.githubusercontent.com/80952b5dfba430b800621a7c818d9c248f462aa21be788f3e73f3cfe150c626e/68747470733a2f2f7472617669732d63692e6f72672f64616d69616e6f70657472756e6761726f2f636c65616e2d6172636869746563747572652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/damianopetrungaro/clean-architecture)

Package for isolate your domain code from framework dependency

What are Domain,Application and Infrastructure layer? [Click here](http://dddsample.sourceforge.net/architecture.html) for a resume.

Why?
----

[](#why)

#### Why did you code this package?

[](#why-did-you-code-this-package)

When I code, I usually isolate the Domain layer from Application layer and Infrastructure layer, and every time I do it I need to re-build a set of objects that helps me doing this.

Those objects often are a Request, a Response and some Errors.

This package is born for me, to avoid re-building such set of objects, also avoiding some copy/paste from different projects.

#### Why should you isolate your domain code from Application and Infrastructure dependencies?

[](#why-should-you-isolate-your-domain-code-from-application-and-infrastructure-dependencies)

Imagine that your PHP application is currently built on top of Laravel framework.

And use a modern frameworks (such Laravel, Symfony or Slim) is a very good thing. Helps you to write a better code without reinvent the wheel.

But what if you want/must switch your current framework for performance, architectural or other reasons to an another one?

Usually this is very painful, and you are despondent to change it. This choose bind you to a tool that might not be as good as before for your project.

And this is only an example. There can be a lot of more reasons why you want to change framework.

#### How can I isolate it?

[](#how-can-i-isolate-it)

Using some DDD concepts, you can totally (or almost) isolate your domain code from the Application layer (Laravel for example) and from the Infrastructure layer (Postgresql or Mysql for example).

So the Domain of my application is not relegated to a particular framework/package/database, and can be "easily" switched.

#### What hepls me to realize this package?

[](#what-hepls-me-to-realize-this-package)

There are some books that helped me to "think" in this way. Here some of them:

[Clean PHP](https://leanpub.com/cleanphp)

[DDD in PHP](https://leanpub.com/ddd-in-php)

[DDD by Evans](https://domainlanguage.com/ddd/)

A Minimal Documentation
-----------------------

[](#a-minimal-documentation)

- Common

    - Collections

        - Collection

            An interface to use instead an array of objects.
        - ArrayCollection

            An implementation of Collection using php array.
    - Enum

        - Enum

            Used for give Enum support on PHP.
        - ReflectionEnum

            An implementation of Enum using reflection.
- Mapper

    - Mapper

        An interface to use for transform object into array and viceversa.
    - UserMapper

        An interface to use for transform User instances into array and viceversa.
- Persistence

    - Transaction

        An interface to use for transaction cross Bounded Contexts.
- Use Cases

    - UseCase

        An interface to use for isolate the use case from the request (CLI,HTTP...).
    - Error

        - Error

            A representation of a generic error in the domain. The error it will be specified using type &amp; code.
        - AbstractError

            An abstract implementation of ErrorInterface.
        - ErrorType

            An interface that extends Enum, used for specify all the error type of your domain.
        - AbstractErrorType

            An implementation of ErrorType.
    - Request

        - Request

            An interface used as DTO for pass data from the infrastructure/application to the domain.
        - CollectionRequest

            An implementation of the Request using Collection.
    - Response

        - Response

            An interface used for pass data from the domain to the infrastructure/application, it uses two main properties Errors: pass all "errors" Data: pass all other "data/information"
        - CollectionResponse

            An implementation of Response using Collection.
    - Validation

        - ValidableRequest

            An interface used for the validate request's data inside the self request
        - ValidableUseCase

            An interface used for the validate request's data inside the UseCase

A Practical Example
-------------------

[](#a-practical-example)

- [Slim](https://github.com/damianopetrungaro/clean-architecture/tree/master/examples/slim)

    This is a simple example of a TODO list of users, using slim microframework and clean architecture package. For any doubt or info add an issue.

Changelog
---------

[](#changelog)

#### \[0.4\] 2018-06-01

[](#04-2018-06-01)

- \[BC\] added a type-hing to `Enum` interface. You need to adapt `equals` method in your class implementing such inteface (or extending `ReflectionEnum` class)

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.5% 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 ~49 days

Recently: every ~105 days

Total

10

Last Release

2951d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/819d5c3f2d019dc8e4d0ad028ee76ef207a2bc201cb7dc70ffe3105e3997d881?d=identicon)[damianopetrungaro](/maintainers/damianopetrungaro)

---

Top Contributors

[![damianopetrungaro](https://avatars.githubusercontent.com/u/8950503?v=4)](https://github.com/damianopetrungaro "damianopetrungaro (86 commits)")[![bigfoot90](https://avatars.githubusercontent.com/u/4598274?v=4)](https://github.com/bigfoot90 "bigfoot90 (5 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (2 commits)")

---

Tags

clean-architectureddddomain-driven-designphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/damianopetrungaro-clean-architecture/health.svg)

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

###  Alternatives

[akaunting/laravel-module

Module management package for Laravel

125254.8k](/packages/akaunting-laravel-module)[riipandi/laravel-optikey

Use UUID, Ulid, or nanoid as optional or primary key in Laravel.

429.3k](/packages/riipandi-laravel-optikey)[aymanalhattami/filament-date-scopes-filter

Filament Date Scopes Filter

1920.2k2](/packages/aymanalhattami-filament-date-scopes-filter)

PHPackages © 2026

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