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

[eluser]regicidedelferoz[/eluser]
good day everyone,

hi, i'm currently studying code igniter and my question is about its URL..

a friend of mine told me that I have to follow the www.domain.com/controller/method/param1/param2/param3 flow of codeigniter..

my current URLnow is www.domain.com/param1/param2/param3 but when i'm calling controller/method i am using the www.domain.com/controller/method/param1/param2/param3

my current route is:
Code:
$route['default_controller'] = "controller"; //default controller

//ajax controller
$route['ajax'] = "ajax";
$route['ajax/(:any)'] = "ajax/$1"; //this follows the www.domain.com/controller/method/param1/param2/param3

//any
$route['(:any)'] = "controller/page/$1"; //the www.domain.com/param1/param2/param3 for displaying pages and its parameters

now my question is.. am I doing the right thing? or my friend is correct that if i would not follow the www.domain.com/controller/method/param1/param2/param3 i should not use codeigniter?


i hope i explained it well..



thanks in advance and more power,
- regicide
#2

[eluser]Harold Villacorte[/eluser]
CI allows you to use convention over configuration. So if you follow the normal controller design convention the routing is done automatically. But as you can see by what you are doing, configuration is also an option but not mandatory. With some other frameworks there is no automatic routing, you have to configure it every time.
#3

[eluser]regicidedelferoz[/eluser]
hello sir harold, thanks for the reply..

in your opinion, should i have to pursue the controller design convention used in CI or i can still go with my configuration?


thanks in advance and more power,
- regicide
#4

[eluser]Harold Villacorte[/eluser]
I can't tell you if it's right or wrong or even if it's best practice because there is no documentation that tells us when and when not to do it. But I can assure that just about every other Codeigniter dev out there is doing the same thing. Some will even go as far as storing slug names in the database and writing code in routes.php to dynamically generate routings. Actually, I believe I am one of those devs.
#5

[eluser]regicidedelferoz[/eluser]
just to clarify, you're one of those devs who do configuration or you just follow CI rules?


thanks in advance and more power,
- regicide
#6

[eluser]Harold Villacorte[/eluser]
Mostly I just follow convention and leave the routings as they are. But there are some urls that just have to rerouted like 'about', 'contact', etc. unless you want to write a controller for each one. The documentation states:

"In some instances, however, you may want to remap this relationship so that a different class/function can be called instead of the one corresponding to the URL."

Further, the tutorial in the documentation also teaches you how to write custom routings. It is one of the first things you learn so you are expected to use it.

So to finally answer your question: Yes and Yes. I do configure the routings and I do follow CI rules.
#7

[eluser]regicidedelferoz[/eluser]
many thanks sir harold Smile




Theme © iAndrew 2016 - Forum software by © MyBB