If your applications are really different, here how I'd do:
Structure:
// src/:
Sybio\Bundle\CoreBundle // Shared entities, config and tools
Sybio\Bundle\PortalBundle // Your main portal, domain.com
Sybio\Bundle\Ps3Bundle // Ps3 bundle
Sybio\Bundle\XboxBundle // Xbox bundle
// etc ...
Perhaps a better thing, add all console bundles inside a "Console" repository:
Sybio\Bundle\CoreBundle // Shared entities, config and tools
Sybio\Bundle\PortalBundle // Your main portal, domain.com
Sybio\Bundle\Console\Ps3Bundle // Ps3 bundle
Sybio\Bundle\Console\XboxBundle // Xbox bundle
// etc ...
CoreBundle is used to share entities between the other bundles, but not only: it will be the bundle that contains specific part of templates that are include on all bundles.
After, you create one web controller per console:
web/app.php // Your main site
web/app_ps3.php // Ps3 app
web/app_xbox.php // Xbox app
// etc...
See inside app_ps3.php, replace the first param of AppKernel constructor by the name of the console:
// ...
$kernel = new AppKernel('ps3', false);
// ...
You can duplicate each controller in dev version if you want, like app_dev.php...
Now, the framework will load different environment depending of the used webcontroller.
For example, your domain "ps3.domain.com" will use web/app_ps3.php (we will see how to do that at the end).
The framework will load the config of the app in app/AppKernel.php:
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
If the visitor hit web/app_ps3.php, the framework will load config_ps3.yml instead of the classical config_dev.php or config_prod.php. You'll now play with bundle dependencies !
Create for each console a "app/config_myconsole.php" and also a "app/routing_myconsole.yml".
In config_ps3.yml (and other consoles), load your general config:
// config_ps3.yml
imports:
- { resource: config.yml }
After this line override the routing inclusion for ps3 routing file:
// config_ps3.yml
// ...
framework:
router:
resource: "%kernel.root_dir%/config/routing_ps3.yml"
To resume, if a user hit web/app_ps3.yml, the file config_ps3.yml is loaded, then the general config.yml file, then routing_ps3.yml (which replace routing.yml).
You can also just import the config of the wanted bundle, for each config file, this can lighten the load if you have many bundles:
// config_ps3.yml
imports:
- { resource: config.yml }
- { resource: "@SybioCoreBundle/Resources/config/services.yml" }
- { resource: @SybioPs3Bundle/Resources/config/services.yml }
Each console application used is own routes, and also some shared routes and actions located in CoreBundle.
For each application, you need to load its console routes and the corebundle routes, here an example of routing_ps3.yml:
// routing_ps3.yml:
SybioCoreBundle:
resource: "@SybioCoreBundle/Controller/"
type: annotation
prefix: /
SybioPs3Bundle:
resource: "@SybioPs3Bundle/Controller/"
type: annotation
prefix: /
If the user hit web/app_ps3.yml, routes from Ps3Bundle and CoreBundle are loaded...
If the user is on http://ps3.domain.com/, il will hit the route "/" from Ps3Bundle, and not the route "/" from another console or from the portal bundle, because you don't load them !
If you've got a generic page, like "/stats/", that is shared between all applications, just create this route in CoreBundle, so that you don't have to duplicate the code on each bundle. As you included CoreBundle routes with Ps3Bundle, the framework will search the route in both bundles.
This route will be accessible here: ps3.domain.com/stats/, xbox.domain.com/stats/...
To finish, the last thing you need to do is to use the right webcontroller depending on the subdomain, here how to process:
// web/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# Hit ps3 app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^ps3\.domain.com$ [NC]
RewriteRule ^(.*)$ app_ps3.php [QSA,L]
# Hit xbox app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^xbox\.domain.com$ [NC]
RewriteRule ^(.*)$ app_xbox.php [QSA,L]
# Hit your main portal
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www\.domain.com$ [NC]
RewriteRule ^(.*)$ app.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
I'm not really comfortable with vhosts, but normally it works !
So that's it, you know how to play with different config to load different applications built on the same core !
Cheers.