Mysqli not found in docker container (php-fpm)

I am running php: 7-fpm in the docker container used by my nginx web server. Everything works well, except when I try to instantiate a mysqli connection in my PHP code. I get the following error:

"NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Class 'Listener\mysqli' not found in index.php:104

Here is my Dockerfile for creating the image, where I explicitly install the mysqli extension:

FROM php:7-fpm

RUN docker-php-ext-install mysqli

It seems to be set to fit the output of phpinfo () below. Do I need to somehow configure or enable it?

enter image description here

+4
source share
1 answer

Your problem is not that you are missing the mysqli extension.

If you are doing something like this:

namespace Listener;

class Foo
{
    public function bar() {
        $conn = new mysqli(...);
    }
}

PHP new mysqli() new \Listener\mysqli(), \Listener. , mysqli() :

$conn = new \mysqli(...);
+2

Source: https://habr.com/ru/post/1676497/


All Articles