2015-06-24 88 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

相關問題