Skip to content
Skills Library
Programming · Building & coding

php-ddd-conventions

/php-ddd-conventions

ACTIVATE when writing or modifying domain layer code in PHP/Symfony, creating value objects, specifications, domain services, or domain interfaces. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity' in PHP context. Provides PHP/Symfony-specific examples for cross-language OOP DDD principles defined in craft:ddd-principles. DO NOT use for: infrastructure/controller code, Doctrine mapping, general architecture questions.

Licence
MIT
Last repository change
12.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

ACTIVATE when writing or modifying domain layer code in PHP/Symfony, creating value objects, specifications, domain services, or domain interfaces. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity' in PHP context. Provides PHP/Symfony-specific examples for cross-language OOP DDD principles defined in craft:ddd-principles. DO NOT use for: infrastructure/controller code, Doctrine mapping, general architecture questions.

Triggers from the description

domainDDDhexagonalports and adaptersdomain purity
Original author description

ACTIVATE when writing or modifying domain layer code in PHP/Symfony, creating value objects, specifications, domain services, or domain interfaces. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity' in PHP context. Provides PHP/Symfony-specific examples for cross-language OOP DDD principles defined in craft:ddd-principles. DO NOT use for: infrastructure/controller code, Doctrine mapping, general architecture questions.

How it works

  1. PHP/Symfony-specific: Forbidden in Domain Layer
  2. PHP/Symfony-specific: Allowed in Domain Layer
  3. PHP/Symfony-specific: SPI Pattern
  4. Quick Reference (PHP-specific)
Original SKILL.md headings · 45 lines, 283 words
SKILL.md preview
---
name: php-ddd-conventions
description: "ACTIVATE when writing or modifying domain layer code in PHP/Symfony, creating value objects, specifications, domain services, or domain interfaces. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity' in PHP context. Provides PHP/Symfony-specific examples for cross-language OOP DDD principles defined in craft:ddd-principles. DO NOT use for: infrastructure/controller code, Doctrine mapping, general architecture questions."
---

# DDD Conventions — PHP / Symfony

> The **cross-language OOP DDD principles** (domain purity, ports & adapters, dependency direction, bounded contexts, aggregates, value objects) are defined in `craft:ddd-principles`. This skill keeps PHP/Symfony-specific lists and patterns.

## PHP/Symfony-specific: Forbidden in Domain Layer

In a Symfony codebase, these concrete classes / types are typical infrastructure leaks:

- `Symfony\Component\HttpFoundation\File\UploadedFile` → use `string $filePath` or a domain abstraction (`UploadFile` model)
- HTTP classes: `Request`, `Response`, `RedirectResponse`, etc.
- Database / ORM: Doctrine entities, repository **implementations**, `EntityManagerInterface`
- Framework-specific validators / constraints (Symfony validator components)

## PHP/Symfony-specific: Allowed in Domain Layer

- Pure PHP types (`string`, `int`, `array`, `DateTimeInterface`, `DateTimeImmutable`)
- Domain value objects (final readonly classes, no framework dependency)
- **Domain interfaces** (defined in `Domain/`, implemented in `Infrastructure/`)
- DTO classes from contracts packages (e.g. `vendor/acme/contracts`)

## PHP/Symfony-specific: SPI Pattern

In a Symfony hexagonal project, the convention for the **Service Provider Interface** (SPI):

- The interface lives in the **Domain** layer (e.g. `src/Domain/Subscription/Port/SubscriptionRepository.php`).
- The concrete implementation lives in **Infrastructure** (e.g. `src/Infrastructure/Doctrine/DoctrineSubscriptionRepository.php`).
- Domain code depends on the interface only.

## Quick Reference (PHP-specific)

| Forbidden in domain | Why |
|---------------------|-----|
| `UploadedFile` | Form-internal type — use domain `UploadFile` |
| `Request` / `Response` | HTTP-internal — should never reach the domain |
| Doctrine entities | ORM-internal — keep domain models pure |
| Symfony validators | Framework-internal — use domain invariants |

| Allowed in domain | Examples |
|-------------------|----------|
| Pure PHP types | `string`, `int`, `DateTimeImmutable`, `array` |
| Domain VOs | `final readonly class Money { … }` |
| Domain interfaces | SPI ports, defined in domain, implemented in infra |
| Contract DTOs | From `vendor/acme/contracts` |

Versions

The database has no other skills named php-ddd-conventions.

Database snapshot: 13.11.2026 · package version c03094d69589 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100ddd-principles
    ACTIVATE when designing the domain layer in OOP languages — bounded contexts, aggregates, value objects, layer purity, ports/adapters, dependency direction. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity', 'bounded context', 'aggregate'. Provides…
  • 95php-refactoring
    ACTIVATE when refactoring PHP code. ACTIVATE for 'refactor', 'extract', 'redesign', 'simplify', or 'clean up' in a PHP/Symfony context. This skill provides PHP-specific examples for the cross-language refactoring rules defined in craft:refactoring-principles. DO NOT use for:…
  • 95clean-architecture
    Provides implementation patterns for Clean Architecture, Hexagonal Architecture (Ports & Adapters), and Domain-Driven Design in PHP 8.3+ with Symfony 7.x. Use when architecting enterprise PHP applications with entities/value objects/aggregates, refactoring legacy code to modern…
  • 100symfony
    Expert Symfony assistance covering PHP HTTP kernel, Twig, Doctrine ORM, services, and MakerBundle. Use when building enterprise PHP applications and web services.
  • 100domain-driven-design
    Use when modeling a domain in Symfony — aggregates, entities, value objects, domain events, repositories, and the ubiquitous language. Use when the task mentions DDD, aggregate, value object, domain event, or invariant.
  • 100tactical-ddd
    Detects anemic domain models, validates and refactors them into rich domain models, and enforces tactical DDD patterns (Entities, Value Objects, Aggregates, Domain Services, Domain Events). Use when the user asks to validate, review, or check domain models or DDD code; detect…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.