I'm new to Codeigniter, and I'm trying to get accustomed to it by converting an old site into CI.
One thing I'm having trouble understand is the routing. If I don't want to have my url structure like /controller/method/id, I have to change it to something like $route['controller/(:num)'] = "controller/method/$1";
in routes.php. It just seems inefficient to me, is there something else I should be doing?
For example, on my site, the urls are /game/4242 and /player/SomeDude
Well, routing is effecient - the alternative is remapping your controllers.
Let's take a look at both possibilities.
An imaginary situtation: At a later point, you'd like to allow your users to show badges/medals/achievements/something on their profile.
With routing, you can achieve it like this:
And your controller could in turn look like this:
}
Basically, this allows you to simply add another method in your controller prefixing the method with
show_
(likepublic method show_friends( $username )
)and you can access it instantly by going to /player/SomeDude/friendsLooking at the alternative, remapping your controller would allow you not to use routes, but write a controller like this:
Personally, I like routing. I think it's transparent and makes my controllers look cleaner.