-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Generating URLs with host matching #6857
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
Comments
This is tricky. I agree it's not nice. Maybe there should be something similar to HttpKernel/Listener/LocaleLister that automatically adds the current host placeholders as default parameters. But the problem is:
|
As a workaround you can set a default that revers to a DIC parameter. One thing that is a bug, is that when its set its used for path() which should only return a relative path not a full URL. |
No updates on this? |
@zachbadgett here I'm using
to define defaults for the routes |
Any news on this? As a workaround I have definied a subdomain listener which has a array of all paths that are protected by subdomain and then redirects to 404 myself if the user tries to access to a route without subdomain. This works but its not pretty. It would perfect to do this at Router level. |
Still no update here? I'm trying to use multiple domains and subdomains for one website. I think something like this should work:
|
here's the update: https://github.com/toaotc/ToaFrameworkExtraBundle.git your configuration:
…so the This is heavily inspired by the LocaleListener. |
Thanks for your little bundle @toaotc, that might be useful. Though, there is no plan to include this kind of functionality in Symfony ? |
You saved my life toatc ! Thanks for this bundle ! |
It seems also not possible, with multiple host requirements for different urls, generate a url from a domain to the other http://stackoverflow.com/questions/34687016/symfony-2-generate-route-with-domain-restrictions-from-another-domain |
@alex88 i assume you use the toaotc/ToaFrameworkExtraBundle. the thing is that it recycles the |
I'm not, anyway, just figured out my issue is something different, the firewall wasn't actually being correctly matched and so it was generating the url for another domain, sorry |
About i18n use cases, #26143 should do it |
The problem is that the Naming conventionThe simplest would be to pass only attributes which respect a certain naming convention. A listener like the one offered by I tried to use some special char like
instead of
when not using special char. Default or new routing configurationAn other solution would be to define some sort of syntax to specify which fragment we want to keep. Something like : web:
resource: ../src/Controller/
type: annotation
host: api.{domain}
defaults:
domain: * or web:
resource: ../src/Controller/
type: annotation
host: api.{domain}
forwards:
- domain To express something like "I want you to use my current If you want to go for this kind of solution, I would gladly submit a PR for it. |
Let's close as per #6857 (comment). PR still welcome. |
Currently running into an issue with the new host matching when I'm trying to generate urls that requires me to pass in a host parameter.
The examples above work perfectly with the url matcher, but when needing to generate the url, it will require me to provide the domain parameter each time. I know this is how it's suppose to function, but it seems a bit annoying to require putting in the domain each time.
The text was updated successfully, but these errors were encountered: