在 Laravel PHP 框架中找不到 PGSQL 驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12396993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PGSQL driver not found in Laravel PHP Framework
提问by Nyxynyx
Hi I am using Laravel PHP framework on CentOS 6.3. I have PostgreSQL 9.1 installed, along with PDO and PDO-PGSQL. Under application/config/database.phpI have set Laravel to use PostgreSQL:
嗨,我在 CentOS 6.3 上使用 Laravel PHP 框架。我安装了 PostgreSQL 9.1,以及 PDO 和 PDO-PGSQL。在application/config/database.php我已经将 Laravel 设置为使用 PostgreSQL:
'default' => 'pgsql',
'connections' => array(
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'dbname',
'username' => 'username',
'password' => 'shhhpass',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
),
However, visiting any page gives me the error:
但是,访问任何页面都会出现错误:
Message:
could not find driver
Location:
/home/dev/public_html/laravel/database/connectors/postgres.php on line 37
Any ideas? Thanks!
有任何想法吗?谢谢!
回答by Omid Kamangar
The line giving that error is this:
给出该错误的行是这样的:
$connection = new PDO($dsn, $username, $password, $this->options($config));
It is trying to load the PDO driver for pg.
它正在尝试为 pg 加载 PDO 驱动程序。
Did you check that the pdo extension is enabled in PHP configuration files?
Check the /etc/php.d/pgsql.iniand /etc/php.d/pdo.ini.
您是否检查过 PHP 配置文件中是否启用了 pdo 扩展?检查/etc/php.d/pgsql.ini和/etc/php.d/pdo.ini。
Hope this helps.
希望这可以帮助。
回答by Koen Schmeets
Run sudo apt-get install php5-pgsqlon your terminal.
sudo apt-get install php5-pgsql在您的终端上运行。
In other words, install the PostgreSQL driver for PHP.
换句话说,为 PHP 安装 PostgreSQL 驱动程序。

