Strike X Posted April 2, 2010 Share Posted April 2, 2010 I have developed basic MVC framework.. The routing does this at the moment: whatever.com/classname/action/value I wanted to create admin backend, I will need a subdirectory with new controller? url will need to look something like this: whatever.com/admin//classname/action/value Do you have any example of code how does subdirectory controller/routing work? Link to comment https://forums.phpfreaks.com/topic/197349-subdirectory-controller-how/ Share on other sites More sharing options...
trq Posted April 2, 2010 Share Posted April 2, 2010 You would simply need to configure a base uri somewhere. If this then has a value of /admin, ignore admin within the uri. Of course, for what your actually doing it sounds like you need to also implement what some frameworks term modules[/m]. So the urls then become whatever.com/modulename//classname/action/value. This way you don't need to setup a new application within /admin, just make it a module of your main application. Link to comment https://forums.phpfreaks.com/topic/197349-subdirectory-controller-how/#findComment-1036178 Share on other sites More sharing options...
Strike X Posted April 3, 2010 Author Share Posted April 3, 2010 You would simply need to configure a base uri somewhere. If this then has a value of /admin, ignore admin within the uri. Of course, for what your actually doing it sounds like you need to also implement what some frameworks term modules[/m]. So the urls then become whatever.com/modulename//classname/action/value. This way you don't need to setup a new application within /admin, just make it a module of your main application. I don't know modules mean for the MVC framework but I managed to get it working if controller file found in the sub directory. Here is example of code: $args = explode('/', $route); if (is_dir($this->pathfolder . $args[0])) { $this->pathfolder = $this->pathfolder . $args[0]; array_shift($args); } if (count($args) > 0) { if (file_exists($this->pathfolder . '/' . $args[0] . '.php')) { $this->controller = $args[0]; } else { // do something if not found. } } Is that ok? Link to comment https://forums.phpfreaks.com/topic/197349-subdirectory-controller-how/#findComment-1036379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.