We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
The following example causes a crash when visiting /test:
/test
<?php use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require __DIR__ . '/../vendor/autoload.php'; /* CAUSES CRASH */ $container = new DI\Container(); AppFactory::setContainer($container); /* CAUSES CRASH */ $app = AppFactory::create(); $app->get('/', function (Request $request, Response $response, array $args) { $response->getBody()->write('Hello World'); return $response; }); $app->redirect('/test', '/'); $app->run();
Crash message:
Details Type: Error Code: 0 Message: Call to a member function createResponse() on null File: vendor/slim/slim/Slim/Routing/RouteCollectorProxy.php Line: 199 Trace #0 vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(42): Slim\Routing\RouteCollectorProxy->Slim\Routing\{closure}(Object(Slim\Http\ServerRequest), Object(Slim\Http\Response), Array) #1 vendor/slim/slim/Slim/Routing/Route.php(374): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\ServerRequest), Object(Slim\Http\Response), Array) #2 vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle(Object(Slim\Http\ServerRequest)) #3 vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest)) #4 vendor/slim/slim/Slim/Routing/Route.php(339): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest)) #5 vendor/slim/slim/Slim/Routing/RouteRunner.php(65): Slim\Routing\Route->run(Object(Slim\Http\ServerRequest)) #6 vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(89): Slim\Routing\RouteRunner->handle(Object(Slim\Http\ServerRequest)) #7 vendor/slim/slim/Slim/MiddlewareDispatcher.php(124): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Http\ServerRequest), Object(Slim\Routing\RouteRunner)) #8 vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): class@anonymous->handle(Object(Slim\Http\ServerRequest)) #9 vendor/slim/slim/Slim/App.php(174): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest)) #10 vendor/slim/slim/Slim/App.php(158): Slim\App->handle(Object(Slim\Http\ServerRequest)) #11 public_html/index.php(23): Slim\App->run() #12 {main}
If you remove the bit between /* CAUSES CRASH */ from my example, the crash goes away.
/* CAUSES CRASH */
The following notice is in my error log:
Undefined property: DI\Container::$responseFactory in vendor/slim/slim/Slim/Routing/RouteCollectorProxy.php on line 199
Using slim/slim 4.1.0 and php-di/php-di 6.0.9.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. So I figured out what's happening. It's because when a container is present this callable gets bound to the container when it's resolved. And as seen we're using $this->responseFactory() when we should just pass it in: https://github.com/slimphp/Slim/blob/4.x/Slim/Routing/RouteCollectorProxy.php#L198-L201
$this->responseFactory()
I'm creating a patch for it right now
Sorry, something went wrong.
Thanks for the quick fix! I can confirm that #2816 fixes the issue.
No branches or pull requests
The following example causes a crash when visiting
/test
:Crash message:
If you remove the bit between
/* CAUSES CRASH */
from my example, the crash goes away.The following notice is in my error log:
Using slim/slim 4.1.0 and php-di/php-di 6.0.9.
The text was updated successfully, but these errors were encountered: