We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multi-site routing... am I doing it right

I've made a multi-site solution in Phalcon, and want to know if this is the best way to do it.

I've made a module site with the devtools, and in /config/config.php, I've done the following:

$frontendRoutes = 'routes.php';
switch ($_SERVER["HTTP_HOST"]) {
    case 'mysite.com':
        $frontendRoutes = 'routes_int.php';
        break;
}

return new \Phalcon\Config(
    array(
        'database' => array(
            'adapter'  => 'Mysql',
            'host'     => 'hhhhhhhhhh',
            'username' => 'uuuuuuuuuu',
            'password' => 'pppppppppp',
            'name'     => 'nnnnnnnnnn',
        ),
        'application' => array(
            'controllersDir' => __DIR__ . '/../controllers/',
            'modelsDir' => __DIR__ . '/../models/',
            'viewsDir' => __DIR__ . '/../views/',
            'cacheDir' => __DIR__ . '/../../cache/'
        ),
        'app' => array(
            'frontendRoutes' => $frontendRoutes,
        )
    )
);

and then, in /config/routes.php:

$config = include __DIR__ . "/config.php";
require(__DIR__ . '/../apps/frontend/config/'.$config->app->frontendRoutes);
require(__DIR__ . '/../apps/admin/config/routes.php');

The reason I'm asking this is because it works, but I don't think it's a very clean solution.

Sorry, no answer - just wanted to mention I've tweaked your post for proper code formatting.

Thanks. I'll use that in the future.