For some reasons I don’t want my users to edit /app/config/config.php to add the database credentials, but in a separate file they add them as an array and my /app/config/config.php is php, not yaml nor xml, so how can I tell /app/config/config.php to get database credentials as an array from another file?
I did look at an application that works like that and I see they use:
That file will need to return the array. I know a lot of people don’t realize that about PHP - you can issue a return statement in an include outside the body of a function. If you do the parsing of that include halts at the return and the value becomes the return of the require statement.
$config = new Configuration;
$config->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\Query\Mysql\Month');
$config->setSQLLogger(new Doctrine\DBAL\Logging\EchoSQLLogger());
$evm = new EventManager;
$evm->addEventListener(Events::loadClassMetadata, new DoctrineExtensions\TablePrefix($db_prefix));
$em = EntityManager::create($dbParams, $config, $evm);
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$platform->registerDoctrineTypeMapping('set', 'string');
I guess this should be possible to tell /app/config/config.php about this bootstrap by implementing:
class ConnectionFactory extends \Symfony\Bundle\DoctrineBundle\ConnectionFactory implements ContainerAwareInterface
{
right? but then how should I tell config.php to care about this file? I guess another possibility is get dbal container from a kernel or controller class and add these configs into it? but nothing is documented. please advice how can I do this all?