Any ideas? 😕
Jun 26, 2020
2
Level 1
Trouble connecting to PostgreSQL database.
When command php artisan migrate is ran, I get this error:
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
+34 vendor frames
35 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
This is my .env file:
DB_CONNECTION=pgsql
DB_HOST=host.docker.internal
DB_PORT=5432
DB_DATABASE=name
DB_USERNAME=user
DB_PASSWORD=secret
And checking phpinfo() within Laravel App, I can confirm that pgsql and pdo_pgsql extensions are installed.
Also by doing php -m inside docker CLI, both extensions are there.
Been on this error for some quite time and still can't figure out what's wrong. I hope someone can help me with this mess... :(
Edit: forgot to add my Dockerfile
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y libpq-dev
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN docker-php-ext-install pdo pdo_pgsql pgsql bcmath
Please or to participate in this conversation.