Symfony override parameters based on host -


i'd load or overwrite parameters depending on host. example, change database or email parameters.

so, created bundle (to reuse in future projects) following extension:

class pceservicesmulticonfigextension extends extension { /**  * {@inheritdoc}  */ public function load(array $configs, containerbuilder $container) {     $configuration = new configuration();     $config = $this->processconfiguration($configuration, $configs);             $rootdir = $container->getparameter('kernel.root_dir');             $request = request::createfromglobals();      $loader = new loader\yamlfileloader($container, new filelocator(__dir__.'/../resources/config'));     $loader->load('services.yml');      // load parameters depending on current host     $paramloader    = new loader\yamlfileloader($container, new filelocator($rootdir.'/config')); // access root config directory     $host                   = $request->gethttphost();             if ($host==":")                 $host               = "localhost";             $parameters = sprintf('parameters_%s.yml', $host);      if (!file_exists($rootdir.'/config/'.$parameters)) {         $parameters = 'parameters_default.yml'; // default     }              echo "load de $parameters";      $paramloader->load($parameters);  } } 

if put echo inside, can see bundle executed parameters in host based file not applied.

many usefull thanks


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -