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
Copy file name to clipboardExpand all lines: README.md
+13-11Lines changed: 13 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,14 +217,16 @@ Groups are designed to be actions that run during the lifecycle of requests to e
217
217
218
218
### Resources
219
219
220
-
Resources allow you to prepare dependencies for requests such as database connection or the user who sent the request. A new instance of a resource is created for every request.
220
+
Resources allow you to prepare dependencies for requests such as database connections or shared services. Register application dependencies on the DI container with `set()`. Runtime values such as `request`, `response`, `route`, `error`, and `context` are scoped by `Http`for each request.
221
221
222
-
Define a resource on the DI container:
222
+
Define a dependency on the DI container:
223
223
224
224
```php
225
-
$container->setResource('timing', function() {
225
+
use Utopia\DI\Dependency;
226
+
227
+
$container->set('bootTime', new Dependency([], function () {
226
228
return \microtime(true);
227
-
});
229
+
}));
228
230
```
229
231
230
232
Inject resource into endpoint action:
@@ -233,21 +235,21 @@ Inject resource into endpoint action:
233
235
$http = new Http(new Server(), 'America/New_York', $container);
0 commit comments