Download the PHP package dhii/containers without Composer
On this page you can find all versions of the php package dhii/containers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package containers
Dhii - Containers
Details
A selection of PSR-11 containers for utility, simplicity, and ease.
Generic
- separates the concern of caching, allowing for caching of any container's values.
CompositeContainer
- A container that is composed of multiple other containers. On key access, iterates over its internal list of containers, and accesses that key of the first container which has that key. Useful for merging configuration from multiple sources, without actually doing any merging.ProxyContainer
- A container that forwards access to 1 other container, which can be assigned after construction. Useful for solving container-related recursive dependency problems, for example for lookup delegation.AliasingContainer
- A decorator that provides access to another container via aliased keys. Useful when an immutable map needs to have its keys changed.MappingContainer
- A decorator that uses a callback to manipulate values retrieved from another container on the fly.PrefixingContainer
- A decorator that allows access to another container's values via prefixed keys. Can also fall back to non-prefixed keys. Useful when e.g. enforcing a prefixing naming convention on keys. The opposite ofDeprefixingContainer
.DeprefixingContainer
- A decorator that allows access to another container's values that have prefixed keys - without the prefix. Useful for e.g. simplification of keys that follow a prefixiing naming convention. The opposite ofPrefixingContainer
.MaskingContainer
- A decorator that selectively hides or exposes keys of another container. Useful when working with maps that have a defined structure.PathContainer
- A decorator that allows access to a hierarchy of nested container via path-like keys. Useful when accessing configuration merged from multiple sources.SegmentingContainer
- A decorator that allows access to a container with delimiter-separated path-like keys as if it were a hierarchy of containers. Useful isolating a segment of configuration when using a path-like naming convention for keys (such as namespacing). The opposite ofPathContainer
.HierarchyContainer
- A container that allows access to a arbitrary hierarchy of arrays as if it was a hierarchy of containers. Creates containers in place, and caches them for future re-use.Dictionary
- Allows access to an array via a container interface, without sacrificing iterability.DataStructureBasedFactory
allows this to be recursive for an array hierarchy of an arbitrary depth. Useful for transforming an array into a container, especially with other decorators.SimpleCacheContainer
- A decorator that presents a PSR-16 cache as a mutable, clearable container with fixed TTL.FlashContainer
- A decorator that presents a value from an inner storage container as another container, copying that value into memory, then clearing it from storage.NoOpContainer
- A no-op writable mutable clearable map that does nothing, and cannot have any values.
DI
- service providers from known maps of factories and extensions.
CompositeCachingServiceProvider
- A service provider that aggregates factories and extensions of other service providers. The results of this aggregation will be cached, meaing that it is only performed at most once per instance - when retrieving said factories or extensions.TaggingServiceProvider
- A service provider that aggregates tagged services into a service with the tag's name.- dependency lookup delegation, which is especially useful when composing a container out of other containers.
Examples
Application Container
Most modern applications use some kind of DI container setup. The below example demonstrates a use-case where all configuration is composed of different sources, accessible via a single source of truth, services are cached per request.
Service Tagging
You can tag your services into a collection. This adds a service with the same name as the tag, which will return a list of services tagged with it.
Since a service name can theoretically be any legal string,
while some limitations need to be set for it to remain a tag,
the tag name can contain any character besides whitespace (anything that matches \s
).
The above example results in the following var_dump()
:
Fun Things With Maps
Maps are very commonly used in applications to represent some key-value relationships. We decided that PSR-11 containers are a great way to represent maps in an interop way. Here are some of the things you can do.
All versions of containers with dependencies
dhii/collections-interface Version ^0.4.0-alpha2
container-interop/service-provider Version ^0.4