https://github.com/thecodingmachine/composite-container-factory
This package provides a factory creating a composite container that automatically detects compatible containers using container-discovery and Puli.
https://github.com/thecodingmachine/composite-container-factory
Last synced: 8 months ago
JSON representation
This package provides a factory creating a composite container that automatically detects compatible containers using container-discovery and Puli.
- Host: GitHub
- URL: https://github.com/thecodingmachine/composite-container-factory
- Owner: thecodingmachine
- Created: 2015-12-14T17:09:58.000Z (over 10 years ago)
- Default Branch: 1.0
- Last Pushed: 2015-12-14T17:50:28.000Z (over 10 years ago)
- Last Synced: 2025-10-20T06:24:41.769Z (8 months ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Composite container factory
===========================
This package provides a factory creating a composite container that automatically detects compatible containers using container-discovery and Puli.
Usage
-----
```php
use TheCodingMachine\CompositeContainer\CompositeContainerFactory;
$compositeContainer = CompositeContainerFactory::get();
```
The `get` method will:
- initialize Puli
- create a composite container
- using Puli, discover all containers that are compatible with [container-discovery](https://github.com/thecodingmachine/container-discovery)
- instantiate all the containers and add them to the composite container
- finally, add Puli instances to the composite container
So the composite container contains all entries of aggregated containers.
The Composite container is of course compatible with container-interop, so you can use `get` and `has` method to fetch services.
**Important**: The `CompositeContainerFactory::get()` method should be called **only once** in your script. Two successive calls will NOT return the same instance.
Puli entries
------------
Those 4 entries will be added to the composite container:
- `puli.factory`: The Puli factory
- `puli.repository`: The Puli repository
- `puli.discovery`: The Puli discovery component
- `puli.asset_url_generator`: The Puli URL generator