问题
Via composer i installed doctrine dbal and symfony2 config component
"require":{
"symfony/dependency-injection": "2.4.*",
"symfony/filesystem": "2.4.*",
"symfony/config": "2.4.*",
"doctrine/dbal": "2.3.4"
}
I autoload them via
require_once __DIR__ . '/vendor/autoload.php'
Then code goes like this
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/app/config/'));
$loader->load('global.yml');
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => 'mydb',
'user' => 'root',
'password' => 'qwerty',
'host' => 'localhost',
'driver' => 'pdo_mysql',
);
$conn = DriverManager::getConnection($connectionParams, $config);
Question is how to load Doctrine DBAL configuration from global.yml file ?
来源:https://stackoverflow.com/questions/22398258/symfony-config-component-and-doctrine-dbal