I want to use the twig function path('route_name') and the router generator's generateUrl method, to render relative links in my symfony project which is multidomain.
The solution sounds simple, while having the routing.yml configered properly and simply calling these methods. But it doesnt work. I would appreciate anyone having the same issue or knowing what the issue could be.
When dumping the $this->container->get('router') i can see the Request host being the one i request: local.domain.com
protected 'generator' =>
object(appDevUrlGenerator)[2301]
protected 'routes' => null
protected 'context' =>
object(Symfony\Component\Routing\RequestContext)[247]
private 'baseUrl' => string '/app_dev.php' (length=12)
private 'pathInfo' => string '/my/link/path' (length=34)
private 'method' => string 'GET' (length=3)
private 'host' => string 'local.domain.com' (length=13)
But calling the method as in symfony official example here: http://symfony.com/doc/current/routing.html#generating-urls
i get the absolute url or rather the url with the default domain written in routing.yml
defaults: { page_domain: domain.com }
I'm not quite sure if this is the problem, since the request carries the proper HOST.
Why does the function not generate a relative URL? If you need any other information for debugging, feel free to ask. I'll post everything you need.
Best Regards, MiKE
page_domain, as far as I know - Dmitry Malyshenko