A DDD Architecture in Laravel — The 4-Layer Structure and Dependency Inversion
Compares traditional Laravel MVC with clean architecture and explains the 4-layer structure (presentation / application / domain / infrastructure), the dependency inversion principle (DIP), the directory layout, and the separation of the Eloquent model from the domain entity.
A Practical Introduction to Laravel × DDD × Clean Architecture
No Laravel experience required. A 20-chapter guide for SPA developers (Vue/React) that explains Laravel as an API backend together with domain-driven design (DDD) and clean architecture, step by step. It covers the theory of value objects, entities, aggregates, and repositories, through to implementation patterns, transactions, testing, and authentication in a Laravel project.
Authentication and Authorization Design — JWT and the Division of Responsibilities Across Layers
Explains the design of authentication and authorization in DDD and clean architecture. Covers the division of responsibilities where authentication lives in the presentation layer and authorization in the application and domain layers, the structure of JWT, the implementation with Laravel × tymon/jwt-auth, access/refresh tokens, and role-based authorization.
Basics of Laravel API Development — Controller, FormRequest, Eloquent, DI
An introduction to API backend development for those new to Laravel. It covers routing, controllers, FormRequest, API Resource, Eloquent ORM, the DI container, Sanctum authentication, and the PHP 8.x syntax used in this book (readonly / enum / constructor promotion).
Conclusion and Next Steps — Introducing DDD Incrementally
Organizes the key points of all 20 chapters of this guide (DDD tactical design / clean architecture / practical techniques / a comprehensive hands-on example), and summarizes a roadmap for incremental adoption—value objects → use case layer → repository → domain events—along with frequently asked questions and recommended books, communities, and learning paths.
Designing the Presentation Layer — FormRequest, Thin Controllers, and API Resources
Explains the design of the presentation layer that handles HTTP requests/responses. Covers format validation with FormRequest, the division of responsibilities with the domain layer, conversion to Commands, thin controllers, API Resources, middleware authentication, and Policy authorization.
Designing the Use Case Layer — Command / Query Separation and DTOs
Explains the design of the application layer (use case layer). Covers its responsibilities of coordinating domain objects, managing transactions, and converting input/output; Command / Query separation based on the CQS principle; Command objects and DTOs; dedicated Query services; and design guidelines such as single responsibility.
Domain Events — Loosely Coupling Aggregates
Explains the DDD domain event (Domain Event) with implementation examples such as OrderConfirmed. It covers loose coupling through event-driven design, the two-phase implementation of recording and dispatching, integration with Laravel Events, synchronous vs asynchronous (ShouldQueue), and the design of idempotency and eventual consistency.
Domain Model and Table Design — Mapping and Indexes
Covers why to design domain-model-first, mapping patterns under the premise that the domain model and tables are not 1:1 (embedding / one aggregate across multiple tables / technical splitting), how the repository absorbs the gap, and index design including the leftmost-prefix rule for composite indexes and its trade-offs.
Eloquentモデルの責務 — 書いていい仕事と書くべきでない仕事
Eloquentモデルが本来担うべき責務(リレーション・アクセサ/ミューテタ・キャスト・ローカルスコープ)と、モデルに書くべきでない責務を、Fat Modelとの対比で整理します。
Error Handling — Mapping Domain Exceptions to HTTP Statuses
Explains error handling in a DDD architecture. Covers an exception hierarchy organized per aggregate, the design of DomainException, mapping to HTTP statuses (404/409/422, etc.) in the Exception Handler, a unified error response, the Result type pattern, a logging strategy, and protecting sensitive information.
Getting Started — Introduction to Laravel × DDD × Clean Architecture
An introduction to DDD and clean architecture with Laravel, aimed at developers experienced with SPA development (Vue/React). It covers who this guide is for, prerequisites, the 20-chapter structure, and an overview of DDD and clean architecture.
In Practice: Implementing the Order System — An Example That Cuts Across All Layers
Integrates the DDD and clean architecture learned so far, implementing the 4 layers (presentation / application / domain / infrastructure) using the order creation and confirmation APIs as the subject. Summarizes each layer's responsibilities, the flow of data transformation, and layered tests (domain / UseCase / Repository) to bring the whole picture together.
PHPクラス設計入門
PHP でクラス設計そのものを入門から実践まで学ぶ全14章のガイド。フレームワーク非依存の設計原則 (カプセル化・単一責任・継承とコンポジション・インターフェース・SOLID) から、Laravel でのモデル/サービスクラス設計まで一気通貫で扱います。
Testing Strategy — The Test Pyramid and Layered Testing
Explains the testing strategy for a DDD architecture. Covers the idea of the test pyramid (Unit / Integration / Feature), the benefit of testing the domain layer fast without a DB, minimal use of mocks, Arrange-Act-Assert, descriptive test method names, and the test data builder pattern.
The Repository Pattern — The Boundary Between Domain and Persistence
Implements the repository pattern with Laravel + Eloquent. Covers why the interface lives in the domain layer (DIP / testability), one aggregate = one repository, mapping between entities and Eloquent Models, the N+1 problem and eager loading, mass-assignment protection, and registration in the DI container.
Transaction Management — Where to Place the Consistency Boundary
Explains transaction management using Laravel's DB::transaction(). Covers the ACID properties, when to place transactions inside the Repository (single aggregate) versus the UseCase (multiple aggregates), nested transactions (savepoints), and the implementation and use cases of optimistic and pessimistic locking.
Why DDD — The Limits of the Fat Controller / Fat Model
Organizes the problems that arise when handling complex business logic in traditional Laravel MVC—Fat Controller, Fat Model, and scattered logic—and explains the four benefits gained by adopting DDD: clarifying business rules, resilience to change, testability, and team communication.
サービスクラスへの責務分割 — Controller肥大化を防ぐ切り出し
Controllerに残った複数の関心事を調整する処理を、サービスクラスへ切り出す判断基準を解説します。単なるファイル分割で終わらせないための凝集度の保ち方も扱います。
まとめ — 実務でクラス設計を判断するために
全13章の判断基準を、実務のコードに向き合うときに使えるチェックリストの形に整理します。次に読むガイドも紹介します。
例外設計とバリデーション — Form Requestとカスタム例外
Form Requestによるリクエストの形式チェックと、カスタム例外クラスによるfail-fastな設計を解説します。
依存性注入とLaravelのコンテナ — 自動解決とインターフェースの結び付け
Laravelのサービスコンテナによる自動解決の仕組みと、インターフェースと実装クラスをbindで結び付ける基本的な使い方を解説します。
実践 — クラス設計のリファクタリング
第8章のFat Controller/Fat Modelを、第9〜12章で見た判断基準を使って通しでリファクタリングします。第1部の原則を総動員する実践編です。
第2部の導入 — Fat Controller/Fat Modelとは何か
第2部の導入。Fat Controller/Fat Modelとは何かを整理し、本パートで扱う範囲(クラス設計止まり)を明示します。