I am trying to connect PostgreSQL with Laravel 5.0 but facing exception "Could not Find Driver in PostgreSQL".
I have tried this solution but cannot connected with PostgreSQL
stackoverflow answer
My database.php config file is following
'default' => 'pgsql'
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forgeUser'),
'password' => env('DB_PASSWORD', '****'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'port' => 5432,
]
PDO extensions are enabled in php.ini
extension=php_pdo.dll
extension=php_pdo_pgsql.dll
when i run following command
php artisan migrate
it gives error
[PDOException] could not find driver
Its working fine when we connect PostgreSQL with Core PHP.
is there any driver still missing in Laravel? Please guide me.
Thank You
You must be ssh'd into your homestead or vagrant box. Then try to migrate.
Related
I am a student and current building a web application for my project.
While trying to host my Laravel application to Heroku my biggest problem at the moment is with the app failing to connect to the MSSQL database, I am using the MSSQL addon for Heroku.
it shows the error when I try to run the app via the App link
"could not find driver (SQL: select top 1 * from [sessions] where [id] = [idstring])"
I've had a similar issue before while setting up the app to run on local. Solved that by downloading the needed drivers on my local system. Now I am lost as to how to do the same for the hosted app on Heroku
Your config/database.php should look something like:
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
]
The Laravel log file reports an error with the configuration. I am configuring the WP database in the .env as being pointed out in the official docs.
The error I got in the Laravel logs:
[2019-08-06 10:23:44] local.ERROR: Database [corcel] not configured.
{"exception":"[object] (InvalidArgumentException(code: 0): Database
[corcel] not configured. at
/Applications/MAMP/htdocs/platform/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:152)
In the config/database.php I have a separate connection for Corcel:
'corcel' => [ // for WordPress database (used by Corcel)
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_WP_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => 'wp_',
'strict' => false,
'engine' => null,
],
...and in the config/corcel.php file I have this line:
'connection' => 'corcel',
...that corresponds to the connection added in config/database.php
The configuration in the .env file I added the WordPress database which should be the source for Corcel:
DB_WP_DATABASE=my_wp_database
The rest of the .env file is the same and I still got no idea why is this throwing config error.
Your config may be cached, could you try running
php artisan config:clear
Is the error happening when you are trying access data? If so you need to specify the connection on your query.
DB::connection('corcel')->table('table_name')
If you are using MAMP, you may need to use unix_socket. In that case you can include unix_socket on the database config like,
'corcel' => [
.....
'unix_socket' => env('DB_SOCKET', ''),
.....
],
On the environment variable(.env file), you may need to use the following,
DB_SOCKET="/Applications/MAMP/tmp/mysql/mysql.sock"
I've just pushed a laravel application to an Ubuntu 16.04 VPS - the company is using SQL Server for record management - and I cannot get Laravel to connect to that database for authentication or anything else.
I'm getting errors that say that Laravel cannot find the drivers to connect.
I've searched in too many places.
There's no good tutorial that shows from start to finish, they're all using different packages and it's overwhelming.
Has anybody here successfully connected a laravel application (running on Ubuntu) to SQL Server?
I have managed using below configuration (on windows):
in .env file
DB_CONNECTION=sqlsrv
DB_HOST=hots
DB_PORT=1433
DB_DATABASE=dbname
DB_USERNAME=user
DB_PASSWORD=password
Database.php
'default' => env('DB_CONNECTION', 'sqlsrv'),
and in connections
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', ''),
'port' => env('DB_PORT', '1433'), // note the port
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'prefix' => '',
],
i started a project with Laravel and PostgreSQL but i can not make the migration.
[Illuminate\Database\QueryException]
could not find drive (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)
[PDOException]
could not find driver
I checked my php.ini and i've uncomment the lines:
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
I restarted the server and when i tried again, the console gives me the same error. I checked my .env file in laravel and it's okay (i think)
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravelPSQL
DB_USERNAME=postgres
DB_PASSWORD=password
and also i checked the database.php and it's okay.
'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', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
]
The last thing i did, was make a file with the function phpinfo() to see if the files of pgsql was enabled and yes.
Honestly i don't know what is happening. I tried in Wamp64, and XAMPP...and nothing. PD. I using Windows 10
I faced the same problem but I solved it by editing my XAMP php.ini file
In php.ini file I un-comment this line:
extension=pgsql
and then it starts working.
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:
[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 .env file
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.php file
'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
sudo apt-get install php-pgsql. This is the command to install php pgsql driver in linux
I had a similar problem using on Ubuntu18.04 using php7.4
Solution:
First check you PHP version with php -v, in my case the version come out to be php7.4 so installed the necessary driver with apt-get install php7.4-pgsql
Finally restart the PHP server
I found the solution there are two php.ini files
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