Changed routing to allow for multiple directories to house controllers. #390

wants to merge 2 commits into


None yet
5 participants

paulrose commented Sep 5, 2011

Added ability for unlimited number of directories to house a controller instead of a single directory level.

I.e. APPPATH.'/controllers/folder1/folder2/folder3/controller.php


dixy commented Jan 14, 2012

Interesting feature.
Any thoughts about it?


ckdarby commented Oct 15, 2012

@dchill42 Is this solved in your HMVC? I haven't been able to keep track of all the stuff you're adding into that.


dchill42 commented Oct 15, 2012

This allows recursion into deeper sub-directories when routing the Controller. At this point, HMVC supports that for module directories, but doesn't change the original routing behavior for the regular package paths.

I think this is a fine idea, but perhaps parallel changes should be made in Loader for other types of objects. One of the reasons I didn't undo the single sub-directory convention under HMVC is that it is standard across all the loadables - one sub only.

@@ -465,7 +471,7 @@ function fetch_method()
function set_directory($dir)
- $this->directory = str_replace(array('/', '.'), '', $dir).'/';

narfbg Oct 15, 2012


You need to sanitize this in order to avoid path injections like these:


satheeshdomainindia pushed a commit to wms-code/CodeIgniter-Standard that referenced this pull request Sep 29, 2013

Merge pull request #390 from jrmadsen67/2
moved auth controller view calls to a _render() function to allow users ...

narfbg added a commit that referenced this pull request Jan 16, 2014

URI Routing overhaul
 - Allow multiple levels of controller directories (supersedes PRs #390, #2439)
 - Add support for per-directory 'defaul_controller' and '404_override' (resolves issue #2611; supersedes PR #939)
 - Fixed a bug where default_controller was called instead of triggering 404 if the current route is inside a directory
 - Removed a few calls from CI_Router to CI_URI that made a necessity for otherwise internal CI_URI methods to be public:

    - Removed CI_URI::_fetch_uri_string() and moved its logic into CI_URI::__construct()
    - Removed CI_URI::_remove_url_suffix, CI_URI::_explode_segments() and moved their logic into CI_URI::_set_uri_string()
    - Removed CI_URI::_reindex_segments() altogether ( doesn't need further manipulation, while  is
      public anyway and can be properly (and more effectively) replaced on the spot)

narfbg commented Jan 16, 2014

Please test this: 30d5324

@narfbg narfbg closed this Jan 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment