Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'd like to propose different solution to your original problem.You can use <a href="http://api.symfony.com/2.3/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.html" rel="nofollow">PhpFileLoader</a> to dynamically define parameters for your config.yml.</p> <ol> <li><p>Extract you main database connection parameters into separate file:</p> <pre><code># src/Blogger/BlogBundle/Resources/config/parameters.yml parameters: main_db_name: maindb main_db_user: root main_db_password: null main_db_host: localhost </code></pre></li> <li><p>Create new PHP script (say DynamicParametersLoader.php) which will inject new parameters in app container. I think you cannot use your symfony app in this script, but you can read main db credentials from $container variable. Like the following:</p> <pre><code># src/Blogger/BlogBundle/DependecyInjection/DynamicParametersLoader.php &lt;?php $mainDbName = $container-&gt;getParameter('main_db_name'); $mainDbUser = $container-&gt;getParameter('main_db_user'); $mainDbPassword = $container-&gt;getParameter('main_db_password'); $mainDbHost = $container-&gt;getParameter('main_db_host'); # whatever code to query your main database for dynamic DB credentials. You cannot use your symfony2 app services here, so it ought to be plain PHP. ... # creating new parameters in container $container-&gt;setParameter('dynamic_db_name', $dbName); $container-&gt;setParameter('dynamic_db_user', $dbUser); $container-&gt;setParameter('dynamic_db_password', $dbPass); </code></pre></li> <li><p>Now you need to tell Symfony about your script and new parameters.yml file:</p> <pre><code># config.yml imports: - { resource: parameters.yml } - { resource: ../../DependencyInjection/DynamicParametersLoader.php } </code></pre></li> <li><p>At this step you can freely use injected parameters in you config:</p> <pre><code># config.yml ... dynamic_conn: dbname: %dynamic_db_name% user: %dynamic_db_user% password: %dynamic_db_password% ... </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload