Download the PHP package fatjon-lleshi/antares-container without Composer
On this page you can find all versions of the php package fatjon-lleshi/antares-container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fatjon-lleshi/antares-container
More information about fatjon-lleshi/antares-container
Files in fatjon-lleshi/antares-container
Package antares-container
Short Description Lightweight autowiring PSR-11 container for PHP 8.2+
License MIT
Homepage https://github.com/johnlesis/antares-container
Informations about the package antares-container
antares-container
Lightweight autowiring DI container for PHP 8.2+. Zero dependencies. Can be used standalone or as part of the Antares framework.
Installation
Standalone Usage
Autowiring
The container resolves classes and their dependencies automatically via reflection. No configuration needed for concrete classes.
Binding Interfaces
Bind an interface to a concrete implementation:
Singletons
Register a class as a singleton — the same instance is returned on every make() call. Use this for classes that require primitive constructor arguments (like config values from .env):
Nested Autowiring
The container recursively resolves nested dependencies:
Error Handling
Unbound Interface
If you try to resolve an interface without binding it, a ContainerException is thrown:
Circular Dependency
Circular dependencies are detected and throw a ContainerException:
Unresolvable Primitive
If a class constructor has primitive type hints (string, int, etc.) with no default values, the container cannot autowire them. Register the class as a singleton instead:
Requirements
- PHP 8.2+
License
MIT