I'm trying to connect with PostgreSQL database through Laravel in order to do a php artisan migrate but doesn't seem to be directed since it's reading the database name of MySQL.
Here are the commands from database.php:
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => __DIR__.'/../database/production.sqlite',
'prefix' => '',
),
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'postgres',
'username' => 'postgres',
'password' => 'root',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
),
),
If I remove the MySQL paths I'll get:
[InvalidArgumentException]
Database [mysql] not configured.
EDIT: When trying to do php artisan migrate I get a 'PDOException: could not find driver'. I'm using WAMP and I'm in Win8.1. Using PostgreSQL as database.
EDIT: Have experimented a series of alternative solutions but I'm still ought to get this solved. The
php.ini
file was checked in Apache, WAMP (from php folder) and PostgreSQL. The extension_dir
is correct as it being -> extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"
The extension=pdo_pgsql.dll
and extension=pgsql.dll
are uncommented.
Done the PATH
trick in the 'System Variables' and rebooted. No chance.
Thanks for the help so far.
These are my drivers php_pdo_driver.h
& php_pdo.h
from C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\php\SDK\include\ext\pdo
Information from phpinfo:
PHP Version 5.5.12
Compiler MSVC11 (Visual C++ 2012) Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\x64\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\x64\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\x64\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
In my case, I had two versions of PHP installed. So all I had to do was use
$ /opt/lampp/bin/php artisan serve
instead of$ php artisan serve
For PHP 7 in Ubuntu you can also do:
So, now you can do not uncomment lines in
php.ini
UPD: I have a same error, so problem was not in driver. I changed my
database.ini
, but every time I saw an error. And I change database config in.env
and errors gone.For
PDOException: could not find driver
forMySQL
, and if it isDebian
based OS,This worked for me:
I am working with 32bit Ubuntu 14
I realize this is an old question but I found it in a Google search so I'm going to go ahead and answer just in case someone else runs across this. I'm on a Mac and had the same issue, but solved it by using HomeBrew. Once you've got it installed, you can just run this command:
And replace the 56 with whatever version of PHP you're using without the decimal point.
Solved after 3 hours... I am using WAMP (PHP 7.2.4), PostgreSQL 10, Laravel 5.6.29. Loaded PHP extensions (pgsql, pdo_pgsql) from Wampserver 3.3, then I was able to connect to the PostgreSQL server with a simple php testcode from the www directory. But
$ php artisan migrate
still returnedI checked the shell (git bash for windows) with
$ php --ini
, that returned C:\wamp64\bin\php\php7.2.4\php.ini instead of c:\wamp64\bin\apache\apache2.4.33\bin\php.ini, loaded by WAMP So you have to uncomment pgsql and pdo_pgsql extensions also in C:\wamp64\bin\php\php7.2.4\php.ini, and then migrate will work ...