Laravel PDO找不到驱动程序

时间:2016-12-15 14:35:01

标签: php sql-server laravel pdo

我正在尝试使用我的Laravel项目设置SQL Server数据库。

我做的事情:

  • 从Microsoft站点下载DLL(我的php 5.6.25版本32)并将它们复制到我的php / ext文件夹。
  • extension = php_sqlsrv_56_nts.dll extension = php_pdo_sqlsrv_56_nts.dll 添加到我的PHP.INI文件中(扩展程序显示在我的phpinfo()中)。
  • 将我的database.php配置文件更改为'default' => env('DB_CONNECTION', 'sqlsrv')

但是:当我尝试迁移我的数据库时,我收到错误:

[PDOException] 
could not find driver

我错过了什么吗?我必须重新检查一些错误的配置?

有什么想法吗?

谢谢!

编辑1: 我在Win7 x64操作系统上使用Wamp x32。

编辑2: 这是使用" -vvv"

运行迁移时出现的错误
Exception trace:
 () at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:55
 PDO->__construct() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:55
 Illuminate\Database\Connectors\Connector->createConnection() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php:32
 Illuminate\Database\Connectors\SqlServerConnector->connect() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:61
 Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}() at n/a:n/a call_user_func() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connection.php:924
 Illuminate\Database\Connection->getPdo() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\DatabaseConnection.php:792
 Illuminate\Database\Connection->reconnectIfMissingConnection() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connection.php:677
 Illuminate\Database\Connection->run() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Connection.php:349
 Illuminate\Database\Connection->select() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Schema\Builder.php:55
 Illuminate\Database\Schema\Builder->hasTable() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Migrations\DatabaseMigrationRepository.php:141
 Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:404 Illuminate\Database\Migrations\Migrator->repositoryExists() at C:\wamp\www\mentoringsecure_html\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php:103
 Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php:58
 Illuminate\Database\Console\Migrations\MigrateCommand->fire() at n/a:n/a call_user_func_array() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Container\Container.php:507
 Illuminate\Container\Container->call() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Console\Command.php:169
 Illuminate\Console\Command->execute() at C:\wamp\www\mentoring\secure_html\vendor\symfony\console\Command\Command.php:256
 Symfony\Component\Console\Command\Command->run() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Console\Command.php:155
 Illuminate\Console\Command->run() at C:\wamp\www\mentoring\secure_html\vendor\symfony\console\Application.php:794
 Symfony\Component\Console\Application->doRunCommand() at C:\wamp\www\mentoring\secure_html\vendor\symfony\console\Application.php:186
 Symfony\Component\Console\Application->doRun() at C:\wamp\www\mentoring\secure_html\vendor\symfony\console\Application.php:117
 Symfony\Component\Console\Application->run() at C:\wamp\www\mentoring\secure_html\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:107
 Illuminate\Foundation\Console\Kernel->handle() at C:\wamp\www\mentoring\secure_html\artisan:36

1 个答案:

答案 0 :(得分:0)

首先:下载正确的dll(对应于你的php版本) -php_pdo_sqlsrv.dll -php_sqlsrv.dll 然后:把它们放在wamp / bin / php / php_yourversion / ext中 最后:在 php.ini 上启用扩展程序 - Wamp使用一个php.ini =>对于浏览器 - PHP使用另一个php.ini =>对于终端