The injector class deals with dependency management as well as object creation and function context invocation.
| api | |
|---|---|
| package | Default |
__construct(\DI\Injector $parent = null)
Provide a parent injector when you wish to optionally override some dependencies but not others
\DI\InjectorThe parent injector to optionally retrieve dependencies from
annotate(callable $callable) : \DI\A
callableThe function to annotate.
\DI\Ano-argument function that invokes the specified function with all of its' parameters dependency injected.bind(string $id, object $instance) : object
stringClass identifier. This must be the fully qualified class name.
objectThe instance to bind to the specified class identifier.
objectThe requested instance.get(string $id) : object
stringClass identifier. This must be the fully qualified class name.
\DI\Interop\Container\Exception\NotFoundException |
if the class identifier was not found. |
|---|
objectThe requested instance.has(string $id) : boolean
stringClass identifier. This must be the fully qualified class name.
booleanTrue if the instance exists, otherwise false.instantiate(string $id) : object
Use Injector->get() if you want to retrieve the same instance each time.
stringClass identifier. This must be the fully qualified class name.
objectThe instance of your class, dependency injected via its' constructor.