CodeIgniter Forums
Controllers sub directory have identical controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Controllers sub directory have identical controller (/showthread.php?tid=63515)



Controllers sub directory have identical controller - Jheysoon - 11-08-2015

    is this a bug ??
I have a controller sub-directory named registrar and also i have a controller named Registrar.php
Whenever i access the sub directory registrar and have a Registration.php i encounter a Page not Found ..

example :: http://localhost/registrar/registration/register...

But when i access the Registrar.php
like :: http://localhost/registrar/method .. it is ok..

But when i renamed the registrar folder it works..

I just want to confirmed if it is a bug...

Sample directory above...


RE: Controllers sub directory have identical controller - sv3tli0 - 11-13-2015

The router will search for a class at first place and after that for dir / class..

In your case it finds class Registrar and there is no method registration so it fails..


RE: Controllers sub directory have identical controller - Jheysoon - 11-15-2015

So CI must have a fallback method for this kind of situation ..??
To search for a controllers/directory/class/method/parameters ...
If it fails to find the controllers/class/method/parameters ...


Thanks for the reply..


RE: Controllers sub directory have identical controller - ciadmin - 11-15-2015

Fallback? CodeIgniter has rules it applies for routing, and developers should avoid having folders and classes with the same name. This may become a non-issue with CI4, but we have to live with what we have for now Undecided


RE: Controllers sub directory have identical controller - sv3tli0 - 11-15-2015

I think that the Default Searching should be as it is
1st - Controller > Method
2nd - Directory > Controller > Method

Don't forget that the routing is auto create for this type of routes. You are always able to define your custom rules at the route configuration..