Discussion:
How to create the route in symfony 2 which maps to external URL?
vishal melmatti
2013-07-26 10:06:20 UTC
Permalink
Hi All,

Referring to this,

http://symfony.com/doc/current/book/routing.html

we can map url pattern to controller and action

# app/config/routing.yml
blog_show:
path: /blog/{slug}
defaults: { _controller: AcmeBlogBundle:Blog:show }

I want to map the path to external url.

# app/config/routing.yml
blog_show:
path: /blog/{slug}
defaults: "www.example.com/blog"

The requirement is, my current website is in kohana, I am porting it
gradually to symfony 2. For my symfony2 app kohana URL are like external
urls, I want to configure these urls in routing and use them in standard
way,

e.g. in Twig,

<a href="{{ path('blog_show'}}">
Read this blog post.
</a>

So later on when I port my pages to Symfony, I will have to change only
routing file so that I could use same blog_show key to refer to url and I
wont' have to change all the files where I have used urls.

Thanks
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Tiago Almeida
2013-07-26 14:22:17 UTC
Permalink
Why not create a controller method that returns a redirect to the correct
URL? In your routing you map the url to that controller method.
Post by vishal melmatti
Hi All,
Referring to this,
http://symfony.com/doc/current/book/routing.html
we can map url pattern to controller and action
# app/config/routing.yml
path: /blog/{slug}
defaults: { _controller: AcmeBlogBundle:Blog:show }
I want to map the path to external url.
# app/config/routing.yml
path: /blog/{slug}
defaults: "www.example.com/blog"
The requirement is, my current website is in kohana, I am porting it
gradually to symfony 2. For my symfony2 app kohana URL are like external
urls, I want to configure these urls in routing and use them in standard
way,
e.g. in Twig,
<a href="{{ path('blog_show'}}">
Read this blog post.
</a>
So later on when I port my pages to Symfony, I will have to change only
routing file so that I could use same blog_show key to refer to url and I
wont' have to change all the files where I have used urls.
Thanks
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Christian Flothmann
2013-07-26 15:17:06 UTC
Permalink
Post by Tiago Almeida
Why not create a controller method that returns a redirect to the correct
URL? In your routing you map the url to that controller method.
I'm not sure if I understood the original problem properly. But for
this to achieve there is no need to create a controller:
http://symfony.com/doc/current/cookbook/routing/redirect_in_config.html

--
jakala
2013-07-27 12:06:28 UTC
Permalink
hello:

i think this is a error concept. in the cookbook, explains how to redirect
to an "internal url" without use a controller... But your problem is to
redirect an "External" url...
Also, in the cookbook really use a controller,

_controller: FrameworkBundle:Redirect:urlRedirect


Maybe the Redirect controller can receives an external url in your
configuration, like this:

root:
path: /blog/{slug}
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: www.example.com/blog

permanent: true


can you try this???
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
---
You received this message because you are subscribed to the Google Groups "Symfony2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...