I've been searching for a way to do this and can't figure it out.
It it possible to store the database config for Symfony2 in a PHP file?
The reason I want to do this is mainly because I usually put the entire "app" in a public directory, but also because of the way I'm attempting to structure my app.
So is there a way to do this?
Your app's configuration by default is in Yaml, but you can configure any part of Symfony to use any configuration type you want.
To configure your app to use PHP, you need to change the code that loads your configuration in the app/AppKernel.php
:
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
You'll need to change this to .php
and write your configuration file in PHP.
Here is what the config.php
file should looks like:
$this->import('parameters.ini');
$this->import('security.yml');
$container->loadFromExtension('framework', array(
'secret' => '%secret%',
'charset' => 'UTF-8',
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
'form' => array(),
'csrf-protection' => array(),
'validation' => array('annotations' => true),
'templating' => array(
'engines' => array('twig'),
#'assets_version' => "SomeVersionScheme",
),
'session' => array(
'default_locale' => "%locale%",
'auto_start' => true,
),
));
// Twig Configuration
$container->loadFromExtension('twig', array(
'debug' => '%kernel.debug%',
'strict_variables' => '%kernel.debug%',
));
You can read more about it here: http://symfony.com/doc/current/book/page_creation.html#application-configuration
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