Phase 2 sub-commit 2: ModelPublisher + #[BridgeResource] + Doctrine listener
Some checks failed
CI / Quality (push) Failing after 1m54s
Some checks failed
CI / Quality (push) Failing after 1m54s
Bundle gains the model layer that bridges Doctrine entities to Mercure
without per-resource glue. Three new pieces:
- `#[BridgeResource(name: ?string)]` attribute marks an entity as a
reactive bridge model. Topic name defaults to the lowercased class
basename and can be overridden per resource.
- `ModelPublisher` translates entity changes into PLAN.md §4 envelopes
({op, id, data, version, ?correlationKey}) and dual-publishes them
on `app://model/{name}` (collection topic) and `app://model/{name}/{id}`
(entity topic). Entity normalisation goes through Symfony's Serializer
(ObjectNormalizer + DateTime + BackedEnum) for predictable JSON. The
envelope `version` field is a per-process monotonic counter — fine for
single-instance dev mode; production should back this with a Postgres
SEQUENCE or equivalent (noted for Phase 4).
- `DoctrineBridgeListener` registers `postPersist`/`postUpdate`/
`postRemove` via `#[AsDoctrineListener]` and routes events through
ModelPublisher. Entities without `#[BridgeResource]` are silently
skipped.
Plus the correlation-key plumbing the §5 Update Semantics layer needs:
- `CorrelationContext` is a per-request holder for the originating
request's `Idempotency-Key`.
- `CorrelationKeyListener` reads the header on `KernelEvents::REQUEST`
and clears the context on `KernelEvents::TERMINATE` (worker mode
hygiene). CLI mutations see no key, which is correct.
Bundle composer.json picks up `doctrine/dbal`, `doctrine/orm`,
`doctrine/doctrine-bundle`, `symfony/serializer`, `symfony/property-*`,
`symfony/uid`. PHPStan extension `phpstan-doctrine` added so the listener's
event-args types resolve. Skeleton's framework.yaml enables `serializer`
and `property_info`.
Tests: 5 new for ModelPublisher (dual publish, correlation echo, delete
op omits data, untagged entities ignored, version increments). Total:
16 tests, 45 assertions, PHPStan clean, cs-fixer clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
109
framework/skeleton/symfony/composer.lock
generated
109
framework/skeleton/symfony/composer.lock
generated
@@ -1199,9 +1199,12 @@
|
||||
"dist": {
|
||||
"type": "path",
|
||||
"url": "../../php",
|
||||
"reference": "d40b6316ce4233eef1bdfdc4be2993b12cbc0e8a"
|
||||
"reference": "57ce5999bb54c35e1a8b61f3bd35c5247baeb730"
|
||||
},
|
||||
"require": {
|
||||
"doctrine/dbal": "^4.0",
|
||||
"doctrine/doctrine-bundle": "^3.0",
|
||||
"doctrine/orm": "^3.0",
|
||||
"php": "^8.3",
|
||||
"symfony/config": "^8.0",
|
||||
"symfony/console": "^8.0",
|
||||
@@ -1209,12 +1212,17 @@
|
||||
"symfony/framework-bundle": "^8.0",
|
||||
"symfony/http-foundation": "^8.0",
|
||||
"symfony/mercure": "^0.7",
|
||||
"symfony/property-access": "^8.0",
|
||||
"symfony/property-info": "^8.0",
|
||||
"symfony/routing": "^8.0",
|
||||
"symfony/security-bundle": "^8.0"
|
||||
"symfony/security-bundle": "^8.0",
|
||||
"symfony/serializer": "^8.0",
|
||||
"symfony/uid": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3",
|
||||
"phpstan/phpstan": "^2",
|
||||
"phpstan/phpstan-doctrine": "^2",
|
||||
"phpstan/phpstan-symfony": "^2",
|
||||
"phpunit/phpunit": "^11",
|
||||
"symfony/phpunit-bridge": "^8.0"
|
||||
@@ -4675,6 +4683,103 @@
|
||||
],
|
||||
"time": "2026-03-30T15:14:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/serializer",
|
||||
"version": "v8.0.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/serializer.git",
|
||||
"reference": "0e3169be25dbf0c23686c8089662cee9dd714932"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/serializer/zipball/0e3169be25dbf0c23686c8089662cee9dd714932",
|
||||
"reference": "0e3169be25dbf0c23686c8089662cee9dd714932",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.4",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"conflict": {
|
||||
"phpdocumentor/reflection-docblock": "<5.2|>=7",
|
||||
"phpdocumentor/type-resolver": "<1.5.1",
|
||||
"symfony/property-info": "<7.4",
|
||||
"symfony/type-info": "<7.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/reflection-docblock": "^5.2|^6.0",
|
||||
"phpstan/phpdoc-parser": "^1.0|^2.0",
|
||||
"seld/jsonlint": "^1.10",
|
||||
"symfony/cache": "^7.4|^8.0",
|
||||
"symfony/config": "^7.4|^8.0",
|
||||
"symfony/console": "^7.4|^8.0",
|
||||
"symfony/dependency-injection": "^7.4|^8.0",
|
||||
"symfony/error-handler": "^7.4|^8.0",
|
||||
"symfony/filesystem": "^7.4|^8.0",
|
||||
"symfony/form": "^7.4|^8.0",
|
||||
"symfony/http-foundation": "^7.4|^8.0",
|
||||
"symfony/http-kernel": "^7.4|^8.0",
|
||||
"symfony/messenger": "^7.4|^8.0",
|
||||
"symfony/mime": "^7.4|^8.0",
|
||||
"symfony/property-access": "^7.4|^8.0",
|
||||
"symfony/property-info": "^7.4|^8.0",
|
||||
"symfony/translation-contracts": "^2.5|^3",
|
||||
"symfony/type-info": "^7.4|^8.0",
|
||||
"symfony/uid": "^7.4|^8.0",
|
||||
"symfony/validator": "^7.4|^8.0",
|
||||
"symfony/var-dumper": "^7.4|^8.0",
|
||||
"symfony/var-exporter": "^7.4|^8.0",
|
||||
"symfony/yaml": "^7.4|^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Serializer\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/serializer/tree/v8.0.8"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/nicolas-grekas",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-03-31T07:15:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"version": "v3.6.1",
|
||||
|
||||
Reference in New Issue
Block a user