我正在用postgres作为数据库开发Laravel 5.我已经配置了postgres 9.4和pgAdmin III,它们工作正常.当我try 运行"迁移"时,它会给我带来错误:

[PDOException]
could not find driver

这是我的数据库.php

'default' => 'pgsql',

'pgsql' => [            'driver'   => 'pgsql',          
                        'host'     => '127.0.0.1',          
                        'database' => 'fms',            
                        'username' => 'postgres',           
                        'password' => 'root',           
                        'charset'  => 'utf8',           
                        'prefix'   => '',           
                        'schema'   => 'public',         ],

Initially I though, it was due to configuration of postgres on windows 7 but I tried with plain php it works perfect

<?php
   $host        = "host=127.0.0.1";
   $port        = "port=5432";
   $dbname      = "dbname=fms";

   $db = pg_connect( "$host $port $dbname user=postgres password=root"  );
   if(!$db){
      echo "Error : Unable to open database\n";
   } else {
      echo "Opened database successfully\n";
   }
?>

I’ve enabled php_pgsql and php_pdo_sql in wamp as well. I’m not sure how to fix this on laravel 5.

推荐答案

As you said you already choosed Default Database as Postgres SQL

'default' => 'pgsql',

It is a must that you need to uncomment the pdo and postgres shared object in your php configuration settings (php.ini)

i.e., You need to uncomment the following lines in your php.ini

extension=pdo_pgsql.so
extension=pgsql.so

Note :

做了这些改变后,别忘了停下来启动你的apache(或者换成php-fpm).

Laravel相关问答推荐

Laravel带S3存储器

如何让 Laravel 的 Collection 表现得像一个流?

在 React 中将属性从一个组件传递到另一个组件

自从 Laravel 使用 Vite 更新后,我无法运行npm run dev

处理程序类中的错误 - Laravel

如何防止 Laravel 路由被直接访问(即非 ajax 请求)

在 laravel 中动态更改时区

如何监控 Laravel 队列是否正在运行?

Laravel 路由将变量传递给控制器

你如何在自定义 Laravel Nova 工具中使用确认对话?

使用 vue-router 更改路由时中止所有 Axios 请求

Array_unique 上一个 laravel Eloquent的集合

Laravel上传文件无法写入目录

干预图像:直接从带有原始文件名和分机的网址保存图像?

Laravel 存储文件的公共 url

如何在 Laravel Mix 中将公共路径更改为包含下划线的内容?

Laravel Eloquent模型如何从关系表中获取数据

在我的编辑器中管理上传文件的最佳方式?

如何使 Laravel (Blade) 文本字段只读

找不到 HOME 环境 -- 扩展 `~'