Welcome Guest, Not a member yet? Register   Sign In
Controller in sub sub directory
#1

[eluser]Firestorm ZERO[/eluser]
I'm organizing my application controllers to make it more manageable and organized.

I can do the following fine...
http://localhost/dir/
http://localhost/dir/welcome/
which maps to my "application/controllers/dir/welcome.php"

But I get a 404s if I do the following..
http://localhost/dir/dir2/
http://localhost/dir/dir2/welcome/
and I have a controller in "application/controllers/dir/dir2/welcome.php"
where "dir" and "dir2" are directories.

Just wondering is this a bug or is it because CI will only look into a directory on the 1st level only?
#2

[eluser]Firestorm ZERO[/eluser]
Anyone? Does CI allow sub-sub directories in controllers?
#3

[eluser]Derek Jones[/eluser]
No, CodeIgniter only looks one subfolder in for controllers.
#4

[eluser]Firestorm ZERO[/eluser]
Just wondering, any reason why? Like the views can have sub-sub directories and I believe models as well. Is it for security reasons?
#5

[eluser]Derek Jones[/eluser]
Views and Models are called from your controller, and you pass a string that indicates the folder structure. The last segment will always be the target view/model, and the rest of the segments will be folders, so there's no recursion to test. Controllers are discovered from your URI, and that same assumption cannot be made. Each segment would have to be individually tested against the file structure to see which segments are folders, which is the controller, and which is the method, and so on. An additional level or two wouldn't really be harmful, but would also be an arbitrary limit; this is simply how the framework was designed. Allowing infinite recursion is probably not a good idea, but you can certainly place a feature request for the architecture to be modified to allow another level of nesting.




Theme © iAndrew 2016 - Forum software by © MyBB