$injector->share('Doctrine\DBAL\Connection'); $injector->delegate( 'Doctrine\DBAL\Connection', function() use($injector) { $dbConfig = require 'mysqlConfig.php'; $config = [ 'dbname' => $dbConfig['database'], 'user' => $dbConfig['username'], 'password' => $dbConfig['password'], 'host' => $dbConfig['host'], 'driver' => $dbConfig['driver'], ]; return \Doctrine\DBAL\DriverManager::getConnection($dbConfig); } );