Laravel SQL Server - PDOException在迁移时找不到驱动程序

时间:2016-11-02 09:42:11

标签: sql-server laravel-5

我有一个laravel 5.2实例,配置为针对MS SQL Server运行。我从microsoft下载了驱动程序,连接运行完美DB::table('usuarios')->select('*')->get();返回:

[{"id":"5","username":"jtd","password":"$2y$10$t8RXYy\/afaEuIpE8GIk2bOvbHsQoj0fhGPxmo\/3UqJABKVA4I4pHC","email":""}]

但是当我尝试php artisan migrate时,我得到了:

  [PDOException]
  could not find driver

为什么会这样?

堆栈追踪:

c:\wamp\www\presence\webapp>php artisan migrate --verbose


  [PDOException]
  could not find driver


Exception trace:
 () at C:\wamp\www\presence\webapp\vendor\laravel\framework\src\Illuminate\Datab
ase\Connectors\Connector.php:55
 PDO->__construct() at C:\wamp\www\presence\webapp\vendor\laravel\framework\src\
Illuminate\Database\Connectors\Connector.php:55
 Illuminate\Database\Connectors\Connector->createConnection() at C:\wamp\www\pre
sence\webapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServ
erConnector.php:32
 Illuminate\Database\Connectors\SqlServerConnector->connect() at C:\wamp\www\pre
sence\webapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connect
ionFactory.php:61
 Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connector
s\{closure}() at n/a:n/a
 call_user_func() at C:\wamp\www\presence\webapp\vendor\laravel\framework\src\Il
luminate\Database\Connection.php:924
 Illuminate\Database\Connection->getPdo() at C:\wamp\www\presence\webapp\vendor\
laravel\framework\src\Illuminate\Database\Connection.php:792
 Illuminate\Database\Connection->reconnectIfMissingConnection() at C:\wamp\www\p
resence\webapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:6
77
 Illuminate\Database\Connection->run() at C:\wamp\www\presence\webapp\vendor\lar
avel\framework\src\Illuminate\Database\Connection.php:349
 Illuminate\Database\Connection->select() at C:\wamp\www\presence\webapp\vendor\
laravel\framework\src\Illuminate\Database\Schema\Builder.php:55
 Illuminate\Database\Schema\Builder->hasTable() at C:\wamp\www\presence\webapp\v
endor\laravel\framework\src\Illuminate\Database\Migrations\DatabaseMigrationRepo
sitory.php:141
 Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()
at C:\wamp\www\presence\webapp\vendor\laravel\framework\src\Illuminate\Database\
Migrations\Migrator.php:404
 Illuminate\Database\Migrations\Migrator->repositoryExists() at C:\wamp\www\pres
ence\webapp\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\
MigrateCommand.php:103
 Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase() at C:\
wamp\www\presence\webapp\vendor\laravel\framework\src\Illuminate\Database\Consol
e\Migrations\MigrateCommand.php:58
 Illuminate\Database\Console\Migrations\MigrateCommand->fire() at n/a:n/a
 call_user_func_array() at C:\wamp\www\presence\webapp\vendor\laravel\framework\
src\Illuminate\Container\Container.php:507
 Illuminate\Container\Container->call() at C:\wamp\www\presence\webapp\vendor\la
ravel\framework\src\Illuminate\Console\Command.php:169
 Illuminate\Console\Command->execute() at C:\wamp\www\presence\webapp\vendor\sym
fony\console\Command\Command.php:256
 Symfony\Component\Console\Command\Command->run() at C:\wamp\www\presence\webapp
\vendor\laravel\framework\src\Illuminate\Console\Command.php:155
 Illuminate\Console\Command->run() at C:\wamp\www\presence\webapp\vendor\symfony
\console\Application.php:794
 Symfony\Component\Console\Application->doRunCommand() at C:\wamp\www\presence\w
ebapp\vendor\symfony\console\Application.php:186
 Symfony\Component\Console\Application->doRun() at C:\wamp\www\presence\webapp\v
endor\symfony\console\Application.php:117
 Symfony\Component\Console\Application->run() at C:\wamp\www\presence\webapp\ven
dor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:107
 Illuminate\Foundation\Console\Kernel->handle() at C:\wamp\www\presence\webapp\a
rtisan:36

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。我发布给大家。我使用WAMP堆栈(PHP,Apache和MySQL)。事实是,wamp使用5.5.12版本的终端CLI,所以我必须在我使用的版本上安装SQL Server PDO Extensions(除此之外)在5.5.12版本上(我安装了几个PHP版本)。如果需要,可以提供更多信息。