定制 damianopetrungaro/clean-architecture 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

damianopetrungaro/clean-architecture

Composer 安装命令:

composer require damianopetrungaro/clean-architecture

包简介

A package of utilities for build clean application in PHP

README 文档

README

Code Climate Build Status

Package for isolate your domain code from framework dependency

What are Domain,Application and Infrastructure layer? Click here for a resume.

Why?

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?

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?

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?

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

Clean PHP

DDD in PHP

DDD by Evans

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 & 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

  • 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

[0.4] 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)

damianopetrungaro/clean-architecture 适用场景与选型建议

damianopetrungaro/clean-architecture 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 340 次下载、GitHub Stars 达 94, 最近一次更新时间为 2017 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 damianopetrungaro/clean-architecture 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 damianopetrungaro/clean-architecture 我们能提供哪些服务?
定制开发 / 二次开发

基于 damianopetrungaro/clean-architecture 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 340
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 94
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 94
  • Watchers: 7
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-09