feature request for reverse routing #1293

Closed
shijialee opened this Issue Apr 26, 2012 · 2 comments

Projects

None yet

3 participants

@shijialee

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?

@cryode
Contributor
cryode commented Apr 26, 2012

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:

  • Conflicts of someone utilizes both (:num) and (:any) for the same route.
    $route['something/(:num)'] = 'something/number/$1';
    $route['something/(:any)'] = 'something/else/$1';
  • Regular Expression support (I didn't look too closely at the code in the link, but noticed that it said he ignores the CI default :num & :any.
  • This would also need to be a major release addition, since it requires the rewrite of the Routes config file.

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
Contributor
narfbg commented Oct 28, 2014

Closing this as duplicate of #218.

@narfbg narfbg closed this Oct 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment