We have a product developed in PHP Symfony framework. We have couple of clients right now for whom we are maintaining different code base and databases (MySql).
They access their respective code base using subdomain like client1.myproduct.com and client2.myproduct.com
Now we want to make a single code base for both the clients and only keep files which are different (in terms of logic) for both of them in separate subdomains.
So both the subdomains will point to the same code base but will access files from their respective subdomains whenever required i.e. whenever logic is different for some feature for both the clients.
Can anyone suggests what is the best way to go about this?
sites: [foo.com, bar.co.uk, www.mike.es]
// index.php
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
// get the domain
$domain = $_SERVER['SERVER_NAME'];
// get rid of www, com, es etc ...
foreach(array('www.', '.com', '.es', '.co.uk') as $crap) {
$domain = str_replace($crap, '', $domain);
}
$confs = array(
'foo' => 'somefoo',
'bar' => 'somebar',
'waz' => 'andwazconfig'
);
$cfg = (!empty($confs[$domain]))
? $confs[$domain]
: 'default';
$configuration = ProjectConfiguration::getApplicationConfiguration($cfg, 'prod', false);
sfContext::createInstance($configuration)->dispatch();
// End of index.php
Hope this helps
Yes you can do so. Symfony Routing can handle this use-case, but it is not one of the easier tasks to do. For a detailed description take a look at the Symfony-Documentation: http://www.symfony-project.org/more-with-symfony/1_4/en/02-Advanced-Routing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With