将 postgres 与 Laravel 连接起来

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43637399/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:51:42  来源:igfitidea点击:

connecting postgres with laravel

phppostgresqllaravellaravel-5laravel-5.4

提问by Fares Izem

Hello i'm trying to connect laravel 5.4 with postgres, after updating the database configuration file and running php artisan migrate, the following error appears:

您好,我正在尝试将laravel 5.4 与postgres 连接,更新数据库配置文件并运行后php artisan migrate,出现以下错误:

[Illuminate\Database\QueryException]
 could not find driver (SQL: select * from information_schema.tables where t
 able_schema = public and table_name = migrations)
[PDOException]
 could not find driver

this is my .envfile

这是我的.env文件

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=Portail
DB_USERNAME=php
DB_PASSWORD=php

and this is my database.phpfile

这是我的database.php文件

'default' => env('DB_CONNECTION', 'pgsql'),
 'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'Portail'),
            'username' => env('DB_USERNAME', 'php'),
            'password' => env('DB_PASSWORD', 'php'),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer', ], 

and i use phpPgAdmin normally

我通常使用 phpPgAdmin

回答by John Simon

sudo apt-get install php-pgsql. This is the command to install php pgsql driver in linux

须藤 apt-get 安装 php-pgsql。这是在linux下安装php pgsql驱动的命令

回答by Fares Izem

I found the solution there are two php.ini files

我发现解决方案有两个 php.ini 文件

  • C:\wamp64\bin\apache\apache2.4.9\bin

  • C:\wamp64\bin\php\php7.0.10

  • C:\wamp64\bin\apache\apache2.4.9\bin

  • C:\wamp64\bin\php\php7.0.10

i must do uncommented php_pdo_pgsql.dll and php_pgsql.dll in the two files thanks for your help all

我必须在这两个文件中执行未注释的 php_pdo_pgsql.dll 和 php_pgsql.dll 感谢大家的帮助