-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slim 4 basepath and request path #2898
Comments
Which PSR-7 implementation are you using with Slim 4? That’s not a problem caused within this repo, more likely in the Slim-Psr7 repo if that’s what you’re using |
Yep, using
|
Yeah, that’s because Slim-Psr7 is modeled after Nyholm/Psr7. This means Slim 3 behavior was irregular. Slim 4 is PSR-7 agnostic, the requests are created via the respective ServerRequest creators of each lib, the internals of Slim 4 don’t change or append Uri properties. |
Ok. In other words expected behaviour. I guess to get routes with path matching the route definition I should either use a custom |
If I may suggest a test. Remove Slim entirely and use Nyholm/ps7 and Nyholm/psr7-server and call the |
Folder gets prefixed. Tested with following code: use Nyholm\Psr7Server\ServerRequestCreator;
use Nyholm\Psr7\Factory\Psr17Factory;
$app->get("/globals", function ($request, $response, $arguments) {
$request = (new ServerRequestCreator(
new Psr17Factory(),
new Psr17Factory(),
new Psr17Factory(),
new Psr17Factory()
))->fromGlobals();
$path = $request->getUri()->getPath();
$response->getBody()->write($path);
return $response;
}) Yields:
|
Let's assume an app which is installed into subfolder
/test
and there is a route such as:Then later in a middleware or a route definition user gets the request path using:
With slim 3 the result is the same as the defined route ie.
foo
. With Slim 4 the result includes the basepath ie it will be/test/foo
. Is this expected behaviour?Example code to demonstrate the problem at:
https://github.com/tuupola/slim-basepath/tree/slim-3
https://github.com/tuupola/slim-basepath/tree/slim-4
The text was updated successfully, but these errors were encountered: