简体   繁体   中英

Doctrine can't find driver pdo_sqlsrv [Windows]

I am building a website in symphony and I am required to use Windows 7 and SQL server 2014 for it. (I'm using php 5.6 in wamp server x64)

I've already checked other similar questions like: Cannot find driver pdo_sqlsrv but they seem not to work and most others are based around the linux version.

into the config.yml of symfony I put:

# Doctrine Configuration
doctrine:
   dbal:
       driver: pdo_sqlsrv

Currently when I try to run

php bin/console doctrine:database:create

from the root folder of my project it gives me the following:

[Doctrine\\DBAL\\Driver\\PDOException]
could not find driver
[PDOException]
could not find driver

I've checked and upon running a simple query in a test file directly onto pdo it works and is also listed with the pdo drivers as [0]=>sqlsrv

As a note the drivers provided by Windows did not work as expected but instead http://robsphp.blogspot.mx/2012/06/unofficial-microsoft-sql-server-driver.html this ones did.

Well I managed to find the solution. First off to stop using apache as the server and instead work with IIS. This solved the problem of the drivers from Microsoft not working.

The next problem was that the connection to the database was rejected constantly. That was solved by enabling TCP IP and assigning a port to IPALL

Hopefully this will be useful to someone.

My solution to this was to call doctrine directly from the fully qualified path to php install. WAMP doesn't want your php versions in PATH, but you need to be able to reach those for doctrine to work, so I do

from project directory:

cd c:\symfony\myProject\
c:\wampsrvr\bin\php\php7.2.4\php bin\console doctrine:schema:update --force

on mac, it's just bin\\console doctrine:schema:update --force

but due to WAMP's weird thing, I had to call it like this. It might not be the perfect solution but I hope it helps. You could make a BAT to the PHP and put that in a shared PATH too.

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