chrisharrison / merged-container
A PSR-11 compliant container that merges a set of PSR-11 containers. You might call it a container container.
Requires
- php: ^7.1
- psr/container: ^1.0
Requires (Dev)
- phpunit/phpunit: ^6.3
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-10-29 05:22:26 UTC
README
A PSR-11 compliant container that merges a set of PSR-11 containers. You might call it a container container.
Requirements
Requires PHP 7.1
Installation
Through Composer, obviously:
composer require chrisharrison/merged-container
Why?
The PSR-11 container interface have the following properties:
- It's immutable. That means it can't be changed after it's been instantiated.
- It doesn't provide an iteration mechanism.
These two properties mean it's difficult to create a container which is a merge of two or more PSR-11 containers.
This library provides a container which implements the PSR-11 interface. It's constructed by an array of other PSR-11 containers. These containers can use any concrete implementation (PHP-DI, Pimple) as long as they implement the PSR-11 interface.
Usage
Create a merged container:
$merged = new MergedContainer([$container1, $container2]);
Use it like any other PSR-11 container.