万本电子书0元读

万本电子书0元读

顶部广告

Domain-Driven Design in PHP电子书

售       价:¥

7人正在读 | 0人评论 9.8

作       者:Carlos Buenosvinos,Christian Soronellas,Keyvan Akbary

出  版  社:Packt Publishing

出版时间:2017-07-07

字       数:46.1万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Real examples written in PHP showcasing DDD Architectural Styles, Tactical Design, and Bounded Context Integration About This Book ? Focuses on practical code rather than theory ? Full of real-world examples that you can apply to your own projects ? Shows how to build PHP apps using DDD principles Who This Book Is For This book is for PHP developers who want to apply a DDD mindset to their code. You should have a good understanding of PHP and some knowledge of DDD. This book doesn’t dwell on the theory, but instead gives you the code that you need. What You Will Learn ? Correctly design all design elements of Domain-Driven Design with PHP ? Learn all tactical patterns to achieve a fully worked-out Domain-Driven Design ? Apply hexagonal architecture within your application ? Integrate bounded contexts in your applications ? Use REST and Messaging approaches In Detail Domain-Driven Design (DDD) has arrived in the PHP community, but for all the talk, there is very little real code. Without being in a training session and with no PHP real examples, learning DDD can be challenging. This book changes all that. It details how to implement tactical DDD patterns and gives full examples of topics such as integrating Bounded Contexts with REST, and DDD messaging strategies. In this book, the authors show you, with tons of details and examples, how to properly design Entities, Value Objects, Services, Domain Events, Aggregates, Factories, Repositories, Services, and Application Services with PHP. They show how to apply Hexagonal Architecture within your application whether you use an open source framework or your own. Style and approach This highly practical book shows developers how to apply domain-driven design principles to PHP. It is full of solid code examples to work through.
目录展开

Title Page

Copyright

Credits

Foreword

About the Authors

Acknowledgments

www.PacktPub.com

Why subscribe?

Customer Feedback

Dedication

Preface

Who Should Read This Book

DDD and PHP Community

Summary of Chapters

Chapter 1: Getting Started with Domain-Driven Design

Chapter 2: Architectural Styles

Chapter 3: Value Objects

Chapter 4: Entities

Chapter 5: Domain Services

Chapter 6: Domain-Events

Chapter 7: Modules

Chapter 8: Aggregates

Chapter 9: Factories

Chapter 10: Repositories

Chapter 11: Application

Chapter 12: Integrating Bounded Contexts

Appendix: Hexagonal Architecture with PHP

Code and Examples

Getting Started with Domain-Driven Design

Why Domain-Driven Design Matters

The Three Pillars of Domain-Driven Design

Ubiquitous Language

Event Storming

Considering Domain-Driven Design

The Tricky Parts

Strategical Overview

Related Movements: Microservices and Self-Contained Systems

Wrap-Up

Architectural Styles

The Good Old Days

Layered Architecture

Model-View-Controller

Example of Layered Architecture

The View

The Controller

Inverting Dependencies: Hexagonal Architecture

The Dependency Inversion Principle (DIP)

Applying Hexagonal Architecture

Command Query Responsibility Segregation (CQRS)

The Write Model

The Read Model

Synchronizing the Write Model with the Read Model

Event Sourcing

Wrap-Up

Value Objects

Definition

Value Object vs. Entity

Currency and Money Example

Characteristics

Measures, Quantifies, or Describes

Immutability

Conceptual Whole

Value Equality

Replaceability

Side-Effect-Free Behavior

Basic Types

Testing Value Objects

Persisting Value Objects

Persisting Single Value Objects

Embedded Value with an Ad Hoc ORM

Embedded Value (Embeddables) with Doctrine >= 2.5.*

Embedded Value with Doctrine <= 2.4.*

Serialized LOB and Ad Hoc ORM

Improved Serialization with JMS Serializer

Serialized LOB with Doctrine

Doctrine Object Mapping Type

Doctrine Custom Types

Persisting a Collection of Value Objects

Collection Serialized into a Single Column

Collection Backed by a Join Table

Collection Backed by a Join Table with Doctrine

Collection Backed by a Join Table with an Ad Hoc ORM

Collection Backed by a Database Entity

NoSQL

PostgreSQL JSONB and MySQL JSON Type

Security

Wrap-Up

Entities

Introduction

Objects Vs. Primitive Types

Identity Operation

Persistence Mechanism Generates Identity

Surrogate Identity

Active Record Vs. Data Mapper for Rich Domain Models

Client Provides Identity

Application Generates Identity

Other Bounded Context Generates Identity

Persisting Entities

Setting Up Doctrine

Mapping Entities

Mapping Entities Using Annotated Code

Mapping Entities Using XML

Mapping Entity Identity

Final Mapping File

Testing Entities

DateTimes

Passing All Dates as Parameters

Test Class

External Fake

Reflection

Validation

Attribute Validation

Entire Object Validation

Decoupling Validation Messages

Validating Object Compositions

Entities and Domain Events

Wrap-Up

Services

Application Services

Domain Services

Domain Services and Infrastructure Services

An Issue of Code Reuse

Testing Domain Services

Anemic Domain Models Vs Rich Domain Models

Anemic Domain Model Breaks Encapsulation

Anemic Domain Model Brings a False Sense of Code Reuse

How to Avoid Anemic Domain Models

Wrap-Up

Domain-Events

Introduction

Definition

Short Story

Metaphor

Real-World Example

Characteristics

Naming Conventions

Domain Events and Ubiquitous Language

Immutability

Modeling Events

Doctrine Events

Persisting Domain Events

Event Store

Publishing Events from the Domain Model

Publishing a Domain Event from an Entity

Publishing your Domain Events from Domain or Application Services

How the Domain Event Publisher Works

Setting Up DomainEventListeners

Testing Domain Events

Spreading the news to Remote Bounded Contexts

Messaging

Syncing Domain Services with REST

Wrap-Up

Modules

General Overview

Leverage Modules in PHP

First-Level Namespacing

PEAR-Style Namespacing

PSR-0 and PSR-4 Namespacing

Bounded Contexts and Applications

Structuring Code in Modules

Design Guidelines

Modules in the Infrastructure Layer

Mixing Different Technologies

Modules in the Application Layer

Wrap-Up

Aggregates

Introduction

Key Concepts

ACID

Transactions

Isolation Levels

Referential Integrity

Locking

Concurrency

Pessimistic Concurrency Control (PCC)

With Doctrine

Optimistic Concurrency Control

With Elasticsearch

With Doctrine

What Is an Aggregate?

What Martin Fowler Says...

What Wikipedia Says...

Why Aggregates?

A Bit of History

Anatomy of an Aggregate

Aggregate Design Rules

Design Aggregates Based in Business True Invariants

Small Aggregates Vs. Big Aggregates

Reference Other Entities by Identity

Modify One Aggregate Per Transaction and Request

Sample Application Service: User and Wishes

No Invariant, Two Aggregates

No More Than Three Wishes Per User

Pessimistic Concurrency Control

Optimistic Concurrency Control

Transactions

Wrap Up

Factories

Factory Method on Aggregate Root

Forcing Invariants

Factory on Service

Building Specifications

Building Aggregates

Testing Factories

Object Mother

Test Data Builder

Wrap-Up

Repositories

Definition

Repositories Are Not DAOs

Collection-Oriented Repositories

In-Memory Implementation

Doctrine ORM

Object Mapping

Doctrine Custom Mapping Types

Entity Manager

DQL Implementation

Persistence-Oriented Repository

Redis Implementation

SQL Implementation

Extra Behavior

Querying Repositories

Specification Pattern

In-Memory Implementation

SQL Implementation

Managing Transactions

Testing Repositories

Testing Your Services with In-Memory Implementations

Wrap-Up

Application

Requests

Building Application Service Requests

Request Design

Use Primitives

Serializable

No Business Logic

No Tests

Anatomy of an Application Service

Dependency Inversion

Instantiating Application Services

Customize an Application Service

Execution

One Class Per Application Service

Multiple Application Service Methods per Class

Returning Values

DTO from Aggregate Instances

Data Transformers

Multiple Application Services on Compound Layouts

AJAX Content Integration

ESI Content Integration

Symfony Sub Requests

One Controller, Multiple Application Services

Testing Application Services

Transactions

Security

Domain Events

Command Handlers

Tactician Library and Other Options

Wrap-Up

Integrating Bounded Contexts

Integration Through the Data Store

Integration Relationships

Separate Ways

Conformist

Implementing Bounded Context Integrations

Modern RPC

Message Queues

Wrap-Up

Hexagonal Architecture with PHP

Introduction

First Approach

Repositories and the Persistence Edge

Decoupling Business and Persistence

Migrating our Persistence to Redis

Decouple Business and Web Framework

Rating an Idea Using the API

Console App Rating

Testing Rating an Idea UseCase

Testing Infrastructure

Arggg, So Many Dependencies!

Domain Services and Notification Hexagon Edge

Let's Recap

Hexagonal Architecture

Key Points

What's Next?

Bibliography

The End

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部