简体   繁体   中英

Symfony doesn't find pdo_sqlsrv driver

I have one problem with Doctrine (or with my server configuration, I don't know where is the problem) in my Symfony2 web. I have been looking for an answer since several days but I haven't found it yet.

I need to connect my symfony web to a remote Microsoft SQL database through Doctrine. For this reason, I have added the "database_driver: pdo_sqlsrv" param in app/config/parameters.yml, but when I try to execute (in my Mac) a command like:

php bin/console doctrine:database:create

or

php bin/console doctrine:generate:entities AppBundle/Entity/Product

I get the following error: [Doctrine\\DBAL\\Driver\\PDOException] could not find driver [PDOException] could not find driver

I have checked the phpinfo and the driver doesn't appear (only mysql, sqlite). I don't know if it's possible to add MSSQL, because in Microsoft SQL Server Functions ( PDO_SQLSRV ) appears that it needs to be running on a Windows.

Is not possible to access a mssql database without Windows? (If yes, how can I do it).

Would I need a Windows hosting?

Thanks in advance.

I'm using sql server on my last project. here is what i've done to make it work on my dev environment

  • install pdo-dblib
  • composer require leaseweb/doctrine-pdo-dblib
  • configure doctrine to use the driver_class from the lib above instead of refering the sql_serv driver

driver_class: Lsw\\DoctrinePdoDblib\\Doctrine\\DBAL\\Driver\\PDODblib\\Driver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM