kool-dev / kool

From local development to the cloud: web apps development with containers made easy.
https://kool.dev
MIT License
667 stars 45 forks source link

Can't use PostgreSQL with CodeIgniter4 #406

Closed kenjis closed 2 years ago

kenjis commented 2 years ago

Describe the bug

Can't use PostgreSQL with CodeIgniter4. It seems pgsql module is not installed.

bash-5.1$ php spark migrate

CodeIgniter v4.1.8 Command Line Tool - Server Time: 2022-02-14 18:24:13 UTC-06:00

Running all new migrations...

[CodeIgniter\Database\Exceptions\DatabaseException]

Unable to connect to the database.
Main connection [Postgre]: Call to undefined function CodeIgniter\Database\Postgre\pg_connect()

Kool version and environment

Kool Version  1.16.0
Kool Bin Path: /usr/local/bin/kool

Docker version 20.10.12, build e91ed57
Docker Bin Path: /usr/local/bin/docker

Docker Compose version v2.2.3
Docker Compose Bin Path: /usr/local/bin/docker-compose

Environment Variables of Interest:

KOOL_NAME=ci4-kool-postgres
KOOL_GLOBAL_NETWORK=kool_global
KOOL_ASUSER=501

To Reproduce

  1. Setup codeigniter and PostgreSQL
  2. Create a controller to connect to the database
<?php
namespace App\Controllers;
class Home extends BaseController
{
    public function index()
    {
        $db = db_connect();
        $db->query('select now()');
    }
}
  1. Navigate to http://localhost/

You will see:

CodeIgniter\Database\Exceptions\DatabaseException #8

Unable to connect to the database.
Main connection [Postgre]: Call to undefined function CodeIgniter\Database\Postgre\pg_connect()

Expected behavior

Can connect to the database.

fabriciojs commented 2 years ago

@kenjis terribly sorry for the delay on this one, totally missed this issue.

Please let me know if this is still an issue; will do some tests on CI preset.