The error message says it. No such service exists.
You must define the DoctrineDBALDriverSQLSrvDriver
class as a symfony service in your public/services.yaml
to autowire it.
Update your public/services.yaml
with:
services:
DoctrineDBALDriverSQLSrvDriver:
autowire: true
But why you will autowire this class? The same behaviour you can get with
public function testConnection(){
$Driver = new Driver();
$connectionParams = array(
'dbname' => 'job',
'user' => 'sa',
'password' => 'Lasernet@2020',
'host' => '192.168.1.34',
'driver' => 'pdo_sqlsrv',
);
$conn = $Driver->connect($connectionParams);
dd($conn);
}
And if you have no really dynamic values in your connection params like $connectionParams['dbname'] = 'sqldb'.$i
, better to use the doctrine dbal config and get the connection with $this->getDoctrine()->getConnection('name');
in your controller.
Symfony Docs
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…