You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that the container only creates instances once. It does not work as a factory. You should consider the Factory Pattern instead:
67
+
Note that the container only creates instances once. It does not work as a factory.
68
+
You should consider the [Factory Pattern](https://designpatternsphp.readthedocs.io/en/latest/Creational/SimpleFactory/README.html) or use the ```create()``` method instead:
67
69
68
70
```php
69
71
use Semperton\Container\Container;
70
72
71
73
class Mail
72
74
{
75
+
public function __construct(Config $c, string $to)
The ```create()``` method will automatically resolve the ```Config``` dependency for ```Mail```.
94
93
95
94
## Configuration
96
95
97
-
You can configure the container with definitions. Closures are always treated as factories and can (!should) be used to bootstrap class instances:
96
+
You can configure the container with definitions. ```callables``` (except invokable objects) are always treated as factories and can (!should) be used to bootstrap class instances:
0 commit comments