thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

remove default language parameter #229

Closed S3lfC0d3r closed 4 years ago

S3lfC0d3r commented 5 years ago

I have Multi language CMS For Front and Admin Page. my default language is en so i don't need to add default language parameter into url.

For English language(default without en):

example.com
example.com/articles/

For France Language(with fr):

example.com/fr
example.com/fr/articles/

How do check/route url parameters without default language?!

delboy1978uk commented 5 years ago

something like this https://docs.zendframework.com/zend-expressive/v3/cookbook/setting-locale-without-routing-parameter/ I'm trying to figure this out myself

philipobenito commented 4 years ago

Will take a look at this for next release in early January

philipobenito commented 4 years ago

I was looking at a possible implementation of this in the next major version but it really doesn't make sense being in the router itself.

You can register multiple routes to respond with the same controller and handle localisation there or in a middleware easily enough.

delboy1978uk commented 4 years ago

Now the router is a request handler in the latest release it's easy to have middleware strip out the language part of the url before the router even gets it's hands on it, so your routes won't need to declare any language segment :-D instead you can set the language as a request attribute in the middleware and pass it on. of course this means using another pipeline and setting the router as the request handler. Maybe a cool future feature could be adding middleware that occurs before the router tries to match :-D