An Update to Dynamic Subdomains for Symfony 1.1
If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter. Thanks for visiting!
In a previous article, we saw how easy it was to enable dynamically loaded Symfony applications via subdomains. Well, the format for the controller files has changed slightly in Symfony 1.1 (most notably, the “SF_” constants have been banished) so here’s an updated version of the previous example index.php front controller:
<?php
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
// get the domain parts as an array
list($tld, $domain, $subdomain, $subdomain2) = array_reverse(explode('.', $_SERVER['HTTP_HOST']));
// determine which subdomain we're looking at
$app = ($subdomain == 'staging') ? $subdomain2 : $subdomain;
$app = (empty($app) || $app == 'www' ) ? 'frontend' : $app;
// determine which app to load based on subdomain
if (!is_dir(realpath(dirname(__FILE__).'/..').'/apps/'.$app))
{
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
}
else
{
$configuration = ProjectConfiguration::getApplicationConfiguration($app, 'prod', false);
}
sfContext::createInstance($configuration)->dispatch();
For the full details of how this file works, be sure to read the previous article.
About this entry
You’re currently reading “An Update to Dynamic Subdomains for Symfony 1.1,” an entry on MirthLab
- Published:
- Friday, August 8th, 2008 at 11:35 am
- Author:
- Mark Quezada
- Category:
- Web Development
- Tags:
- application, controller, subdomain, symfony, symfony 1.1

1 Comment
Jump to comment form | comments rss