---
title: Shared Domain Bases
type: entity
created: 2026-09-06
updated: 2026-09-06
sources: [codebase snapshot 2026-09-06]
tags: [shared, entity, aggregate-root, domain-event, value-object]
---

# Shared Domain Bases

`Domain\Shared` holds the abstract primitives every aggregate and value object in the project extends. These define the project's notion of identity, equality, and event recording.

> **Note on provenance:** reflects the code as of 2026-09-06; no written ADR exists.

## Files

- `src/Domain/Shared/Entity.php` — abstract base for entities. Holds `protected mixed $id`, exposes `id()`, and implements `equals(Entity $other)` by class + id (delegating to the id VO's `equals()` when the id is an object).
- `src/Domain/Shared/AggregateRoot.php` — extends `Entity`. Adds domain-event recording: `record(DomainEvent)` and `pullEvents(): array`. See [domain-events](../concepts/domain-events.md).
- `src/Domain/Shared/DomainEvent.php` — abstract base for domain events, carries `occurredAt()` `DateTimeImmutable`.
- `src/Domain/Shared/ValueObject.php` — abstract base for value objects, declares `equals(ValueObject): bool` and provides `isEqualTo()`.

## Role in the architecture

These are the **only** shared types that cross bounded contexts. Every aggregate (`Board`, `Ticket`, `Workspace`, `User`) extends `AggregateRoot`; every id VO (`BoardId`, `TicketId`, `WorkspaceId`, `UserId`) extends `ValueObject`. See [identity-value-objects](../concepts/identity-value-objects.md).

## Observations / open questions

- **`AggregateRoot` only handles event recording, not dispatch.** Dispatch is manual, in the command (see [domain-events](../concepts/domain-events.md)).
- **No aggregate records events today** — `Board`, `Ticket`, `Workspace`, and `User` all return empty `pullEvents()` (the template's `Order` event was removed with the demo slice).
- The `Entity::equals()` logic (class + id) is shared; it's reasonable but couples equality to the id VO's `equals()`.

## Related pages

- [identity-value-objects](../concepts/identity-value-objects.md) — the id model
- [domain-events](../concepts/domain-events.md) — how events flow
- [ddd-layering](../concepts/ddd-layering.md) — why this layer is pure PHP
- [overview](../overview.md) — project context