Welcome Guest, Not a member yet? Register   Sign In
Why ROUTES ?
#1

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

Huh Huh Huh
Reply
#2

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.
Reply
#3

Also, it's good practice to not make your url routes depend on your naming conventions for controllers/methods.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#4

(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 ?
Reply
#5

(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 ?
Reply
#6

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
Reply
#7

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
On the package it said needs Windows 7 or better. So I installed Linux.
Reply
#8

(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.
Reply
#9

SEF = Search Engine Friendly
Reply
#10

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" ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB