php - Mount operation in Silex - additional trailing slash -


i have small backend developed in silex framework. try make request work on post:

http://localhost/feedback/other

but when using mount operation request works:

http://localhost/feedback/other/

as can see must add additional trailing slash request.

here code doesn't work expected:

//index.php $app->mount("/other", new feedbackother());  //feedbackother.php $feedbackother->get("/", "feedbackothercontroller::index")->bind('other'); $feedbackother->post("","feedbackothercontroller::store"); 

if

//index.php $app->post('/other', "feedbackothercontroller::store"); $app->mount("/other", new feedbackother());  //feedbackother.php $feedbackother->get("/", "feedbackothercontroller::index")->bind('other'); 

the post request works without additional slash, in case don't see point in using mount operation.

also i've tried using .htacces rewrite rewrite rule transforms post request in get.

there difference between mounting collection of routes , limiting route post. adding mount means collection of routes being created under specific namespace, in case /other. meaning default url namespace /other/ - trailing slash required too. not apply when define routes specific method, such post. in short - expected behaviour in both silex , symfony well. there heavy discussion in github while ago, let me copy/paste notes fabien left (the author):

let me explain current behavior of mounted routes understand behavior explained several people in thread (and behavior same 1 in symfony, applies symfony well).

the simplest url possible / (an empty url not mean , silently converted browsers /, when requesting http://google.com, actual request http://google.com/).

when mount route collection under prefix, silex/symfony creates new "namespace" urls. when define / in route collection , mount under /foo, url access route /foo/. requesting /foo in case not make sense.

so, of today, not possible define callback /foo when mounting route collection under /foo. can see limitation of current behavior can't think of possible solution not feel hackish.

if you're interested in whole story - this quote taken.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -