feat: unify all integrations on single Symfony-based container with dumped cache#675
Merged
Conversation
…n LiteApplication
73304ff to
a20e01a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this change proposed?
Ecotone maintained five separate container implementations — EcotoneLite's lazy in-memory container, the Symfony bundle's container merge, Laravel's per-definition singleton registration, Tempest's in-memory adapter, and LiteApplication's PHP-DI compilation. Each duplicated the same orchestration (cache handling, definition resolution, gateway exposure) with its own code and performance profile, and every new framework integration had to re-implement all of it.
This PR replaces all of them with one shared container system for Ecotone: a single Symfony-DI-based container in the main package that compiles once and dumps to a plain PHP file. Production boots
requirethe dumped container — no annotation scanning, no definition building, no reflection — bringing Symfony-grade container caching to every integration. Because every framework now runs the same container, this opens the door for the next performance improvements to be delivered from a single place (dump format, lazy services, preloading) and benefit all integrations at once.It also keeps user-land containers clean: Ecotone internals no longer leak into the application's container. Only the required services — Message Buses, Gateways, console commands, connection factories — are bridged into the framework container, while everything else stays inside Ecotone's own compiled container. The public surface stays 1:1: gateway/bus autowiring, console commands, and
getGatewayByName()all work as before.Description of Changes
packages/Ecotone/src/SymfonyContainer/module: converts Ecotone definitions to a SymfonyContainerBuilder, dumps viaPhpDumperon cache-enabled boots, and wraps everything in a PSR-11EcotoneContainerwith lazy fallback to the framework container (two-way bridge: external references resolve lazily through a syntheticecotone.external_container; gateways/buses are bridged back into the framework container).EcotoneSymfonyContainerFactory::bootstrap()— cache hit loads the dumped container, cache miss lazily builds the messaging configuration. Old implementations (LazyInMemoryContainer,InMemoryContainerImplementation,SymfonyContainerAdaptermerge, PHP-DI) are removed;php-di/php-didependency dropped,symfony/dependency-injectionadded toecotone/ecotone.ContainerCacheLayout(config-hash cache invalidation), typed accessors (getRegisteredConsoleCommands(),getDefinedServiceIds(),getConfigHash()), andregisterBridgesInto()for gateway exposure — each framework integration is now just config mapping + a PSR adapter + bridge closures.Usage examples
Nothing changes for end users — same APIs, now cache-backed everywhere:
Use cases
Boot flow
flowchart TD A[Framework boot] --> B{Dumped container\nfor config hash?} B -- hit --> C[require opcache-served loader stub] B -- miss --> D[Scan annotations -> MessagingSystemConfiguration] D --> E[Convert definitions to Symfony ContainerBuilder] E --> F{Cache enabled?} F -- yes --> G[Compile + PhpDumper dump] --> C F -- no --> H[Use ContainerBuilder directly] C --> I[EcotoneContainer wrapper] H --> I I -- outbound --> J[Lazy delegate to framework container\nfor user services] I -- inbound --> K[Bridge Message Buses, Gateways, console commands\ninto framework container]Benchmarks — full HTTP request through the whole application
Measured locally with phpbench on the example applications. This is the complete HTTP-stack benchmark: every request boots the entire application — framework kernel startup, container loading, Ecotone, and request handling — not just the Ecotone part. Run with opcache + opcode file cache enabled, mirroring how production amortizes compilation across processes.
All package suites green (Ecotone 1275, Laravel, Symfony, Tempest, LiteApplication, Dbal, EventSourcing, Kafka, Amqp, SQS, Redis + 87 cross-module tests).
Pull Request Contribution Terms