Closed adjenks closed 5 years ago
Type hinting does not work, however, this works:
$app->get('', function (Request $request, Response $response) {
return $this->call(function(Request $request, Response $response){
return $response;
},[\DI\get('response')]); // "dependency injection based on explicit definition"
});
Requests and responses are not services, they are not autowired.
In controllers (get()
method) they are injected not as services, but with a specific feature of https://github.com/PHP-DI/Invoker.
As described on this page: http://php-di.org/doc/container.html#call Call should perform autowiring when the container has the available .
Results in:
Because get() correctly autowired, whereas call() did not.