Files
php-qml/framework/php/composer.json
magdev 1c5a5761f6
Some checks failed
CI / Quality (push) Failing after 1m54s
Phase 2 sub-commit 2: ModelPublisher + #[BridgeResource] + Doctrine listener
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>
2026-05-02 02:32:51 +02:00

55 lines
1.7 KiB
JSON

{
"name": "php-qml/bridge",
"description": "Symfony bundle bridging PHP applications to a Qt/QML host (part of the php-qml framework).",
"type": "symfony-bundle",
"license": "proprietary",
"require": {
"php": "^8.3",
"symfony/framework-bundle": "^8.0",
"symfony/mercure": "^0.7",
"symfony/security-bundle": "^8.0",
"symfony/routing": "^8.0",
"symfony/http-foundation": "^8.0",
"symfony/console": "^8.0",
"symfony/dependency-injection": "^8.0",
"symfony/config": "^8.0",
"symfony/serializer": "^8.0",
"symfony/property-access": "^8.0",
"symfony/property-info": "^8.0",
"symfony/uid": "^8.0",
"doctrine/dbal": "^4.0",
"doctrine/orm": "^3.0",
"doctrine/doctrine-bundle": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^11",
"phpstan/phpstan": "^2",
"phpstan/phpstan-symfony": "^2",
"phpstan/phpstan-doctrine": "^2",
"friendsofphp/php-cs-fixer": "^3",
"symfony/phpunit-bridge": "^8.0"
},
"autoload": {
"psr-4": {
"PhpQml\\Bridge\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PhpQml\\Bridge\\Tests\\": "tests/"
}
},
"scripts": {
"phpstan": "phpstan analyse --memory-limit=512M",
"cs:check": "php-cs-fixer check --diff --allow-unsupported-php-version=yes",
"cs:fix": "php-cs-fixer fix --allow-unsupported-php-version=yes",
"phpunit": "phpunit",
"quality": [
"@phpstan",
"@cs:check",
"@phpunit"
]
},
"minimum-stability": "stable"
}