Closed carc1n0gen closed 6 years ago
In PHP-DI closures are shortcuts to the factory()
definition. But if you use any other kind of callable you need to use factory()
explicitly, else PHP-DI will not consider it as a factory.
What happens here instead is that the NotFoundProvider
class is considered as the service, and so Twig calls it as the "not found handler" with a $request
parameter.
Have a look here for more details: http://php-di.org/doc/php-definitions.html#factories
Awesome thanks, I'll use this approach
Hello, I am having trouble switching from anonymous function to a callable class when building my services:
For some reason I get an instance of
Slim\Http\Request
instead of the container passed when the callable gets called.PHP Fatal error: Call to undefined method Slim\Http\Request::get()
EDIT: I tried type hinting the container with no luck:
PHP Catchable fatal error: Argument 1 passed to App\Providers\SessionMiddlewareProvider::__invoke() must implement interface Psr\Container\ContainerInterface, instance of Slim\Http\Request given