bcit-ci / CodeIgniter

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
18.27k stars 7.61k forks source link

feature request for reverse routing #1293

Closed shijialee closed 9 years ago

shijialee commented 12 years ago

New to php and CI... I would hate to hard-code url in my template. a way to reverse mapping the routes from config/routs.php would be really nice.

Looks like there isn't such feature in CI and I found one here http://codefury.net/2010/09/easy-reverse-routing-with-codeigniter/ it is "an extension for the CodeIgniter Router class that I wrote that gives you a nice way to write routes that are reversible and also have the ability to take parameters."

What do you think?

AkenRoberts commented 12 years ago

This is an interesting feature. I can see the desire for it, but I think that desire comes at a price.

This feature's purpose is to make changing URLs easy, without needing to replace code in multiple places. That's always handy, but what happens when you change a URL on a website that is well-established? How will Google know where the new page is? How will your users? I think this makes it easy for people to forget to set up appropriate HTTP redirects and that sort of thing.

Some other things of note:

Personally, I have never had an issue hardcoding URLs into an application. But I can see how this would be handy. I think it could use some more discussion.

narfbg commented 9 years ago

Closing this as duplicate of #218.