24 Jun 2009

multiple applications in symfony using subdomains

Posted by havvg

You might have thought about it – me too :) It’s one simple way to use subdomains to manage the chosen application of your symfony project.

?Download index.php
<?php
 
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
 
switch ($_SERVER['HTTP_HOST'])
{
        case 'backend.megacomplex.de':
                $configuration = ProjectConfiguration::getApplicationConfiguration(
                        'backend',
                        'prod',
                        false);
        break;
 
        case 'mkt.megacomplex.de':
                $configuration = ProjectConfiguration::getApplicationConfiguration(
                        'mkt',
                        'prod',
                        false);
        break;
 
        case 'nopaste.megacomplex.de':
                $configuration = ProjectConfiguration::getApplicationConfiguration(
                        'nopaste',
                        'prod',
                        false);
        break;
 
        default:
                $configuration = ProjectConfiguration::getApplicationConfiguration(
                        'game',
                        'prod',
                        false);
        break;
}
 
sfContext::createInstance($configuration)->dispatch();

That’s the index.php I’m using for Megacomplex. On the other hand you will have to setup your webserver correctly!

Tags:

Subscribe to Comments

One Response to “multiple applications in symfony using subdomains”

  1. [...] are some hacks (here, here and here) on the net that allows you to define the application and environment based on the domain. [...]

     

Leave a Reply

Message: