'Lumen - Postgresql setup - Composer
really strugling on this one, it's not the first I try to set this up but I really can't see why it's not working.
So this is my app.docker file:
FROM php:7-fpm
# Install modules
RUN buildDeps="libpq-dev libzip-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev " && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install pdo pdo_pgsql pgsql gd
WORKDIR /var/www
COPY . /var/www
RUN chown www-data:www-data -R ./storage
RUN ln -s /storage/app/public /public
Pretty simple. Next comes the output of phpinfo()
I understand that the pgsql driver is now installed, however, when running php artisan migrate I still get
This is my config/database.php file.
return [
'default' => 'postgres',
'migrations' => 'migrations',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST'),
'database' => env('DB_DATABASE'),
'port' => env('DB_PORT'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'mysql_postal_code' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE_POSTAL_CODE'),
'port' => env('DB_PORT'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'postgres' => [
'driver' => 'pgsql',
'host' => env('DB_PG_HOST', 'database_p'),
'database' => env('DB_PG_DATABASE', 'dockerApp'), // This seems to be ignored
'port' => env('DB_PG_PGSQL_PORT', 5432),
'username' => env('DB_PG_USERNAME', 'postgres'),
'password' => env('DB_PG_PASSWORD', 'secret'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public'
]
],
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];
What can I be missing?
Solution 1:[1]
solution: you need to run the following commands on your terminal;
php -version : to get your exact PHP version for example in my case i get
mykmyk@skynet:/var/www/practicefolder/BooksCharactersAPI$ php -version
PHP 8.0.18 (cli) (built: Apr 21 2022 10:14:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.18, Copyright (c) Zend Technologies
with Zend OPcache v8.0.18, Copyright (c), by Zend Technologies
mykmyk@skynet:/var/www/practicefolder/BooksCharactersAPI$
as shown above my php-version is 8.0.18 then use this "php version number" in the below command , still on your terminal:
sudo apt-get install php8.0-pgsql
Notice i plugged in my exact PHP version 8.0.18 , in the command php8.0-pgsql leaving out the last digit. so in your case yours will be "sudo apt-get install phpx.x-pgsql", x.x designating your PHP version number.
After this try out the migrate command again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | bitbuoy |