GithubHelp home page GithubHelp logo

laraclean's Introduction

LaraClean

Clean Architecture sample with Laravel

Laravel で実践クリーンアーキテクチャの形に組んでみました。
詳しい解説は下記解説をご覧ください。
Laravelで実践クリーンアーキテクチャ: https://qiita.com/nrslib/items/aa49d10dd2bcb3110f22

また次の記事もあわせていただくと参考になるでしょう。
実践クリーンアーキテクチャ: https://nrslib.com/clean-architecture/
実装クリーンアーキテクチャ: https://qiita.com/nrslib/items/a5f902c4defc83bd46b8

どれがどれにあたるか

どの実装が図におけるどれにあたるかを書いておきます。

同心円

いつもの

いつもの図です。

Controllers

  • App\Http\Controllers\UserController

UseCases

  • packages\UseCase\User\Create\UserCreateUseCaseInterface
  • packages\UseCase\User\GetList\UserGetUseCaseInterface
  • packages\Domain\Application\User\UserCreateInteractor
  • packages\Domain\Application\User\UserGetListInteractor
  • packages\MockInteractor\User\MockUserCreateInteractor
  • packages\MockInteractor\User\MockUserGetInteractor

Entities

  • packages\Domain\Domain 以下

Presenters

MVC フレームワークにおいては相性が悪いので採用していません。
ただ Laravel では再現できる方法があるという情報を聞いているので調査後実装予定です。

Gateways

  • packages\Domain\Domain\User\UserRepositoryInterface
  • packages\Infrastructure\User\UserRepository
  • packages\InMemoryInfrastructure\User\InMemoryUserRepository

Interface と Adapter です。

同心円の図の右下

右下の図

案外わかりやすい右下の図です。

Controller

  • App\Http\Controllers\UserController

通常の MVC フレームワークのコントローラです。
ヘキサゴナルアーキテクチャのアダプタにあたります。

UseCaseInputPort

  • packages\UseCase\User\Create\UserCreateUseCaseInterface
  • packages\UseCase\User\GetList\UserGetUseCaseInterface

UseCaseInteractor

  • packages\Domain\Application\User\UserCreateInteractor
  • packages\Domain\Application\User\UserGetListInteractor
  • packages\MockInteractor\User\MockUserCreateInteractor
  • packages\MockInteractor\User\MockUserGetInteractor

UseCaseOutputPort

このプロジェクトでは採用していません
UseCaseOutputPort を採用したプロジェクトは次の URL をどうぞ!
https://github.com/nrslib/StrictLaraClean

Presenter

このプロジェクトでは採用していません
Presenter を採用したプロジェクトは次の URL をどうぞ!
https://github.com/nrslib/StrictLaraClean

クラス図

クラス図みたいなの

左上から書いていきます。

Controller

  • App\Http\Controllers\UserController

InputData

  • packages\UseCase\User\Create\UserCreateRequest
  • packages\UseCase\User\GetList\UserGetRequest

InputBoundary

  • packages\UseCase\User\Create\UserCreateUseCaseInterface
  • packages\UseCase\User\GetList\UserGetUseCaseInterface

UseCaseInteractor

  • packages\Domain\Application\User\UserCreateInteractor
  • packages\Domain\Application\User\UserGetListInteractor
  • packages\MockInteractor\User\MockUserCreateInteractor
  • packages\MockInteractor\User\MockUserGetInteractor

Entities

  • packages\Domain\Domain 以下

DataAccessInterface

  • packages\Domain\Domain\User\UserRepositoryInterface

OutputData

  • packages\UseCase\User\Create\UserCreateResponse
  • packages\UseCase\User\GetList\UserGetResponse

OutputBoundary

このプロジェクトでは採用していません
OutputBoundary を採用したプロジェクトは次の URL をどうぞ!
https://github.com/nrslib/StrictLaraClean

Presenter

このプロジェクトでは採用していません
Presenter を採用したプロジェクトは次の URL をどうぞ!
https://github.com/nrslib/StrictLaraClean

ViewModel

  • App\Http\Models 以下

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.