2015-06-24 38 views
1

我正在上使用Postgre数据库Laravel项目,我跑Laravel 5找不到合适的驱动程序Postgre SQL

php artisan migrate 

然后我得到错误

[PDPException] could not find driver 

但我所有的驱动程序是正确的安装并启用我的php.ini。我有一个使用Postgre并且工作正常的Yii应用程序。 php_pdo_pgsql已经安装并启用。

这是我在Laravel

<?php 

return [ 

/* 
|-------------------------------------------------------------------------- 
| PDO Fetch Style 
|-------------------------------------------------------------------------- 
| 
| By default, database results will be returned as instances of the PHP 
| stdClass object; however, you may desire to retrieve records in an 
| array format for simplicity. Here you can tweak the fetch style. 
| 
*/ 

'fetch' => PDO::FETCH_CLASS, 

/* 
|-------------------------------------------------------------------------- 
| Default Database Connection Name 
|-------------------------------------------------------------------------- 
| 
| Here you may specify which of the database connections below you wish 
| to use as your default connection for all database work. Of course 
| you may use many connections at once using the Database library. 
| 
*/ 

'default' => 'pgsql', 

/* 
|-------------------------------------------------------------------------- 
| Database Connections 
|-------------------------------------------------------------------------- 
| 
| Here are each of the database connections setup for your application. 
| Of course, examples of configuring each database platform that is 
| supported by Laravel is shown below to make development simple. 
| 
| 
| All database work in Laravel is done through the PHP PDO facilities 
| so make sure you have the driver for your particular database of 
| choice installed on your machine before you begin development. 
| 
*/ 

'connections' => [ 

    'sqlite' => [ 
     'driver' => 'sqlite', 
     'database' => storage_path('database.sqlite'), 
     'prefix' => '', 
    ], 

    'mysql' => [ 
     'driver' => 'mysql', 
     'host'  => env('DB_HOST', 'localhost'), 
     'database' => env('DB_DATABASE', 'forge'), 
     'username' => env('DB_USERNAME', 'forge'), 
     'password' => env('DB_PASSWORD', ''), 
     'charset' => 'utf8', 
     'collation' => 'utf8_unicode_ci', 
     'prefix' => '', 
     'strict' => false, 
    ], 

    'pgsql' => [ 
     'driver' => 'pgsql', 
     'host'  => '192.168.3.9', 
     'database' => 'qms', 
     'username' => 'postgres', 
     'password' => 'postgres', 
     'charset' => 'utf8', 
     'prefix' => '', 
     'schema' => 'public', 
    ], 

    'sqlsrv' => [ 
     'driver' => 'sqlsrv', 
     'host'  => env('DB_HOST', 'localhost'), 
     'database' => env('DB_DATABASE', 'forge'), 
     'username' => env('DB_USERNAME', 'forge'), 
     'password' => env('DB_PASSWORD', ''), 
     'charset' => 'utf8', 
     'prefix' => '', 
    ], 

], 

/* 
|-------------------------------------------------------------------------- 
| Migration Repository Table 
|-------------------------------------------------------------------------- 
| 
| This table keeps track of all the migrations that have already run for 
| your application. Using this information, we can determine which of 
| the migrations on disk haven't actually been run in the database. 
| 
*/ 

'migrations' => 'migrations', 

/* 
|-------------------------------------------------------------------------- 
| Redis Databases 
|-------------------------------------------------------------------------- 
| 
| Redis is an open source, fast, and advanced key-value store that also 
| provides a richer set of commands than a typical key-value systems 
| such as APC or Memcached. Laravel makes it easy to dig right in. 
| 
*/ 

'redis' => [ 

    'cluster' => false, 

    'default' => [ 
     'host'  => '127.0.0.1', 
     'port'  => 6379, 
     'database' => 0, 
    ], 

], 

]; 
+0

我也有这个问题。你在使用什么操作系统?你解决了这个问题吗?如果是这样,你可以在这里添加一个答案,以便其他人可以从中学习? – dKen

回答

0

配置您将需要doctrine/dbal包使用的Postgres。 https://packagist.org/packages/doctrine/dbal

这通过要求包添加到您的应用程序:

composer require doctrine/dbal

+0

你可以详细了解为什么需要安装它,它会产生什么效果?我和上面的@Joene有同样的问题,添加这个包没有任何作用。 – dKen

+0

如果我没有弄错,雄辩使用教义包。一旦你安装Laravel,dbal one就是可选的。这个包增加了必要的图层以便与psql交谈。此外,如果这没有帮助,我想你的PHP扩展为pdo pgsql不活跃。 – Luceos

+0

谢谢@Luceos,欣赏信息。烦人的是,我可以通过PGSQL运行查询。 PHP在我的Apache服务器上和通过CLI,所以它看起来像一切工作,因为它应该,只是我的迁移显示错误:(你确定雄辩使用学说,或者他们是替代另一个? ](http://culttt.com/2014/06/30/getting-started-doctrine-2-laravel/)。是否有任何有关DBAL的官方文档可以阅读,以便在我去之前了解是否需要这些 – dKen

相关问题