-
Notifications
You must be signed in to change notification settings - Fork 12
UrlMap not interpreting REQUEST_URI correctly #9
Comments
Tested it on the dev server, works for me.
<?php
require "vendor/autoload.php";
use Stack\CallableHttpKernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$app = new CallableHttpKernel(function ($req) {
return new Response("app");
});
$foo = new CallableHttpKernel(function ($req) {
return new Response("foo");
});
$map = new Stack\UrlMap($app, [
'/foo' => $foo
]);
$resp = $map->handle(Request::createFromGlobals());
$resp->send(); On the shell:
Request in the browser: http://localhost:4000/app_dev.php/foo and you should get "foo" Make sure that you request this code really through |
Your example works correctly, but I invite you to try it with Stack\Builder and a fresh Symfony install. There's either a problem, or the documentation isn't clear enough on how to handle this. |
Ok, looking into it. Am Dienstag, 13. August 2013 schrieb Jarrod Nettles :
Christoph Hochstrasser |
Re-opening, just so this does not get lost. |
I had to use it today and I confirm that the issue exists. In my app, when i access site via app_dev.php, $server['SCRIPT_FILENAME'] = $server['SCRIPT_NAME'] = $server['PHP_SELF'] = $server['SCRIPT_NAME'] . $path; cc @Blackshawk |
@defrag Could you please post the complete file with your code? |
@Blackshawk: What web server are you using? Here is my code: <?php
require "vendor/autoload.php";
use Stack\CallableHttpKernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Stack\UrlMap;
use Stack\Builder;
$app = new CallableHttpKernel(function ($req) {
return new Response("app");
});
$foo = new CallableHttpKernel(function ($req) {
echo "<pre>";
print_r($_SERVER);
echo "</pre>";
return new Response("foo");
});
$app = (new Builder)
->push(UrlMap::class, [
'/foo' => $foo
])
->resolve($app);
$resp = $app->handle(Request::createFromGlobals());
$resp->send(); |
@Blackshawk: Will try it with a fresh Symfony install too. |
@Blackshawk: Tried it with a completely fresh Symfony 2.3 install and it works with I added only this to my <?php
$kernel = (new Stack\Builder)
->push(Stack\UrlMap::class, [
'/foo' => new Stack\CallableHttpKernel(function ($req) {
return new Response("foo");
})
])
->resolve($kernel); |
@defrag @Blackshawk Which web server gives you this issues? Apache, NGINX or the builtin dev server? |
@CHH Well it will work with the CallableHttpKernel with simple response like you showed, but it will not work with symfony2 app kernel. In my case I have FeatureKernel that extends AppKernel, which have some associated webservices that needs to be mock per feature. foreach ($fakeWs as $key => $value) {
$map['/' . $key] = $featureKernel;
}
$stack = (new Stack\Builder)
->push('Stack\UrlMap', $map)
; Then im accessing page like app_dev.php/FEATURE-123/ and it boots kernel with needed data. If i will not change the server variables like I mentioned in sample before, all routings etc will totally mess. Try mapping new AppKernel instead of CallableHttpKernel and You will see errors. |
Have the same problem with lighttpd and fpm. |
In situations where there is a file prefix in the REQUEST_URI, UrlMap incorrectly includes it as part of the intended route.
For example, in Symfony during development, you usually visit the app through
local.dev/app_dev.php/my/action
and Symfony is smart enough to compute the /my/action route automatically, chopping off the app_dev.php.StackPHP does not chop off this file prefix. It seems to me that this should be the expected behavior.
You can easily reproduce this issue by using two middlewares and UrlMap through a file in the URL.
The text was updated successfully, but these errors were encountered: