framework
framework copied to clipboard
Auto-dispatch subdomain to module
http://admin.example.com
will auto route to and load admin module
How about if you set a default module to router:
$this->di->set('router', function () use ($request) {
$router = new Router();
switch ($request->getServer('HTTP_HOST')) {
case 'admin.example.com':
$router->setDefaultModule('admin');
break;
default:
$router->setDefaultModule('front');
break;
}
return $router;
});