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"
Be sure to configure the
'default'
key inapp/config/database.php
For postgres, this would be
'default' => 'postgres',
If you are receiving a
[PDOException] could not find driver
error, check to see if you have the correct PHP extensions installed. You needpdo_pgsql.so
andpgsql.so
installed and enabled. Instructions on how to do this vary between operating systems.For Windows, the
pgsql
extensions should come pre-downloaded with the official PHP distribution. Just edit yourphp.ini
and uncomment the linesextension=pdo_pgsql.so
andextension=pgsql.so
Also, in
php.ini
, make sureextension_dir
is set to the proper directory. It should be a folder calledextensions
orext
or similar inside your PHP install directory.Finally, copy
libpq.dll
fromC:\wamp\bin\php\php5.*\
intoC:\wamp\bin\apache*\bin
and restart all services through the WampServer interface.If you still get the exception, you may need to add the postgres
\bin
directory to yourPATH
:PATH
entry.This should hopefully resolve any problems. For more information see:
In Windows 8 PC with Laragon 3.4.0 180809, I faced the same issue. It happened in my case because I updated Laragon and it added a new version of PHP. So in
laragon/bin/php/
I actually had two directories:php-7.1.20-Win32-VC14-x64
php-7.1.7-Win32-VC14-x64
I added
7.1.20
into myPATH
variable. But in my Command Console, runningphp --ini
was showing that the path actually was fetching from the older one:php-7.1.7-Win32-VC14-x64
. So I deleted the old one (for safety, I put it in Recycle Bin). But Laragon failed to start after that.So, in
laragaon/etc/apache2/mod_php.conf
, I changed the path to the latest PHP version. Then restarted Laragon and the issue is resolved.I see you are using Windows. I was not able to fix this with enabling any of the extensions that come with my Windows WAMP Server. I tried PDO_ODBC and others and even found the Microsoft Official PDO_SQLSRV.
The solution for me was to install the PDO_SQLSRV drivers from a 3rd party website. I found the drivers through http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html
I usually don't use DLLs from random websites, but I was desperate and this worked for me. Hoping it might save others numerous hours of frustration.
For those wanting to use Postgresql on OpenSuse (and co), try the following:
I was on shared hosting and there I had to enable all the
pdo