Over the time i developed my own framework and it's working great - it's light, it's fast and is proven that can handle decent load.
Now I'm working on project that can be described as a online shop where every user will have his sub domain where his items will be available for sale.
My framework works by splitting request url by / and determening what is the controller, actions params.. etc..
and that works just fine, but what to do with subdomains?
i've modified my reqest object, so when i type lets say:
(i added SeverAlias *.shop.local )
this is how my request object look like:
DPLS_Request Object
(
[_request] => Array
(
[0] =>
[1] =>
[action] => defaultAction
[controller] => home
)
[_params] => Array
(
)
[_rurl:private] => kodi.shop.local
[_segment] => kodi
[get_params] => Array
(
)
)
so _segment is the subdomain, and later i can use it in code to validate it vs username and other stuff but i'm having conceptual problems even before that. my problem is that my framework expect some controller and actions to be passed, and because all he gets at the end of URL is / he assumes that it shoud display index page :(
so what to do next ... how to incorporate subdomains in whole mvc controllers/actions story?
one quick and dirty sollution is to modify part of my request class:
if($this->_request['controller']==''){
$this->_request['controller'] = DEFAULT_CONTROLLER;
}
if($this->_request['action']==''){
$this->_request['action'] = DEFAULT_ACTION;
}
and to wrap that in yet another if to test if _segment is present, and if it is then assign to controller DEFAULT _SHOP _CONTROLLER, which i will define in config file as lets say 'store'
so the request above will be analog to typing http://shop.local/store/ (it will run 'store' controller and default action)
what would you do in this case? is there any "best practice" when dealing with subdomains and controllers and actions?