CodeIgniter Forums
Why ROUTES ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Why ROUTES ? (/showthread.php?tid=68375)

Pages: 1 2


Why ROUTES ? - marceloc - 07-01-2017

Why is it necessary to specify routes in the config.php file if there are actions in the controller ?

Huh Huh Huh


RE: Why ROUTES ? - ivantcholakov - 07-02-2017

1. It is config/routes.php (CodeIgniter 3).
2. There are action methods, indeed. But often the action name alone is not enough to specify the link and the request. There may be parameters, request method detection, need for prettifying links - this is additional information that needs a place where to be defined - usually within routes.php.


RE: Why ROUTES ? - albertleao - 07-02-2017

Also, it's good practice to not make your url routes depend on your naming conventions for controllers/methods.


RE: Why ROUTES ? - marceloc - 07-02-2017

(07-02-2017, 03:01 AM)ivantcholakov Wrote: 1. It is config/routes.php (CodeIgniter 3).
2. There are action methods, indeed. But often the action name alone is not enough to specify the link and the request. There may be parameters, request method detection, need for prettifying links - this is additional information that needs a place where to be defined - usually within routes.php.

" There may be parameters, request method detection, need for prettifying links - this is additional information that needs a place where to be defined - usually within routes.php."

Do you mean a place to VALIDATE the routes within the user´s request ?


RE: Why ROUTES ? - marceloc - 07-02-2017

(07-02-2017, 08:56 AM)albertleao Wrote: Also, it's good practice to not make your url routes depend on your naming conventions for controllers/methods.

and what does prevent me of perpeatuating my naming conventions also in routes.php ?


RE: Why ROUTES ? - ciadmin - 07-02-2017

It isn't *necessary* to specify routes in config/routes.php, the config settings allow you to specify any routing which would not resolve properly with segment-based routing.

You can also do some funky routing with the _remap() function inside a controller Undecided


RE: Why ROUTES ? - rtenny - 07-03-2017

I mainly use it for SEF URL to controller mapping.
I dont want a Controller that is called /best-villas-in-the south-of-mallorca
with the routes this url will go to the villas controller


RE: Why ROUTES ? - marceloc - 07-03-2017

(07-03-2017, 07:54 AM)rtenny Wrote: I mainly use it for SEF URL to controller mapping.
I dont want a Controller that is called /best-villas-in-the south-of-mallorca
with the routes this url will go to the villas controller

I´m sorry, rtenny. I didn´t understand a word of what you typed.


RE: Why ROUTES ? - PaulD - 07-03-2017

SEF = Search Engine Friendly


RE: Why ROUTES ? - marceloc - 07-03-2017

What about "I dont want a Controller that is called /best-villas-in-the south-of-mallorca
with the routes this url will go to the villas controller" ?