通过作曲家我安装了学说 dbal 和 symfony2 配置组件
"require":{
"symfony/dependency-injection": "2.4.*",
"symfony/filesystem": "2.4.*",
"symfony/config": "2.4.*",
"doctrine/dbal": "2.3.4"
}
我通过自动加载它们
require_once __DIR__ . '/vendor/autoload.php'
然后代码是这样的
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);
问题是如何从 global.yml 文件加载 Doctrine DBAL 配置?