zloynick / joole-components-container
Installs: 13
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:joole-component
Requires
- php: 8.1.*
- zloynick/joole-containers: ^8.1.3
- zloynick/joole-framework: ^8.1.3
- zloynick/joole-reflector: ^2.1.5
This package is not auto-updated.
Last update: 2024-10-09 22:24:41 UTC
README
This component allows you to register containers with objects, "pulling" dependencies from other containers. The component is based on the joole-containers library.
Getting started
- Install this dependency via composer:
composer install zloynick/joole-components-container
Configuration
Add to components this in your joole.php configuration file:
'components' => [
...,
[
'name' => 'containers',
'class' => \joole\components\containers\ContainersComponent::class,
// Containers and their configuration.
'options' => [
'main' => [
...,
['class' => \joole\reflector\Reflector::class,],
...,
],
// You also can use dependencies for object building with:
'my_custom_container' => [
...
[
'class' => '\YourClass',
// A "YourClass" object will be created using a Reflector object from another container
// if there is a "Reflector" type parameter in the object constructor.
'depends' => [
[
'class' => \joole\reflector\Reflector::class,
'owner' => 'main',
],
]
],
],
// The component also accepts input parameters for objects. Each of the parameters
// is a data type and it is important to understand this.
'events_container' => [
[
'class' => '\EventStack',
// EventStack::__construct(bool $cleanAfterExecution, array $allowedEvents)
'params' => [
'cleanAfterExecution' => true,
'allowedEvents' => [
'\CustomEvent1',
'\CustomEvent2',
],
],
]
]
],
'routes' => __DIR__.'/routes/',
],
...,
],