I want to build Laravel + PostgreSQL existing Project.
config.php
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL', "pgsql://postgres:[email protected]:5432/crawler"),
'host' => env('DB_POSTGRES_HOST', '127.0.0.1'),
'port' => env('DB_POSTGRES_PORT', '5432'),
'database' => env('DB_POSTGRES_DATABASE', 'crawler'),
'username' => env('DB_POSTGRES_USERNAME', 'postgres'),
'password' => env('DB_POSTGRES_PASSWORD', '123'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer'
],
I tried to migrate the database.
But error occured.
IlluminateDatabaseQueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE')
at E:Taskcookie.crawler.backend.apivendorlaravelframeworksrcIlluminateDatabaseConnection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
Exception trace:
1 DoctrineDBALDriverPDOException::("could not find driver")
E:Taskcookie.crawler.backend.apivendordoctrinedballibDoctrineDBALDriverPDOException.php:18
2 DoctrineDBALDriverPDOException::new(Object(PDOException))
E:Taskcookie.crawler.backend.apivendordoctrinedballibDoctrineDBALDriverPDOConnection.php:44
Please use the argument -v to see more details.
What’s the reason.
I’ve installed PostgreSQL recently and not familiar with this.
2
Answers
I just got an answer. Find php.ini in xampp/php folder. add 2 things. extension=pdo_pgsql extension=pgsql If exist, remove ; from the line. It will works well.
The error message you are receiving means that you do not have the PostgreSQL driver installed for PHP, and therefore Laravel is unable to connect to the database, resulting in an error.
Check if the PostgreSQL driver is installed :
If not installed:
After installing , restart your web server:
If you are using Windows,
Download the PostgreSQL driver and place the downloaded file in your PHP installation directory. For example, choose the path
and
find the following line in the php.ini file:
;extension=php_pgsql.dll
and uncomment it by removing the semicolon at the beginning of the line.