slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.94k stars 1.95k forks source link

issue #2831 revived getting the same issue #2985

Closed nielsnl68 closed 4 years ago

nielsnl68 commented 4 years ago

Hello, I have the same issue as in issue #2831.

As suggested i added the addRoutingMiddleware middleware just before $app->run() but sadly i still get the same error message. Using the skeleton from jerfeson i have the following route:

  $app->any('/', function (Request $request, Response $response, $args) use ($app) {
      return $app->resolveRoute('Welcome', 'index', $args, '\App\Controllers');
  });

And in the 'Welcome' controller class i have this:

use Psr\Http\Message\ServerRequestInterface as Request;

class Welcome 
{
    public function index(Request $request)
    {
        $routeContext = RouteContext::fromRequest($request);
        $route = $routeContext->getRoute();

        return $this->render( '@site/test/welcome.twig'   );
    }
}
odan commented 4 years ago

The strange thing is that the jerfeson/slim4-skeleton puts the request and response object into the IoC container. See here. For me it looks like the jerfeson/slim4-skeleton doesn't use the request object correctly, because the request/response object is context specific and doesn't belong into the container. At the end the routing information are not available there.

This line also doesn't match with the parameter list of resolveRoute.

return $app->resolveRoute('Welcome', 'index', $args, '\App\Controllers');

I think this is not a Slim, but more a jerfeson/slim4-skeleton specific issue. Maybe create an issue here.

nielsnl68 commented 4 years ago
Thank you Daniel, I will look in to that, somehow I think it must be more …  because as soon I removed that code the whole system breaks down. In the end I could contact hem indeed.   Met Vriendelijke groetenNiels v/d Spek From: Daniel OpitzSent: zaterdag 18 juli 2020 14:50To: slimphp/SlimCc: nielsnl68; AuthorSubject: Re: [slimphp/Slim] issue #2831 revived getting the same issue (#2985) The strange thing is that the jerfeson/slim4-skeleton puts the request and response object into the IoC container. See here. For me it looks like the jerfeson/slim4-skeleton doesn't use the request object correctly, because the request/response object is context specific and doesn't belong into the container. At the end the routing information are not available there.This line also doesn't mach with the parameter list of resolveRoute.return $app->resolveRoute('Welcome', 'index', $args, '\App\Controllers');I think this is not a Slim, but more a jerfeson/slim4-skeleton specific issue. Maybe create an issue here.—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.