Install extension for php through exec command

Hello,

i try to install extension for php through exec container command and it work for php but not for me)

but i can’t use it inside my php file, example:

$conf = new \RdKafka;
->Undefined class 'RdKafka' 

why does not it work for me and how can i force it?

Can you rephrase your question? I could not completely understand it.

What do you do to install an extension, using what Docker image exactly and what is the error message?

What do you mean by that it works for php but not for you?

Hi

I can understand a few words and thus perhaps am I not wrong by thinking you’re trying to create a PHP docker container here rdkafka is installed.

Here is the first link retrieved in Google : docker-php-fpm-rdkafka-alpine/Dockerfile at master · blastworksinc/docker-php-fpm-rdkafka-alpine · GitHub

Hello,

I have docker container based on php_8.2_apache_container and trying to install extension inside it through:

docker exec -it container_name bash

do instruction from

finally, my index.php has one command:

print_r(phpinfo());

and i see

but if i try to use namespace of RdKafka inside index.php i have error:

use RdKafka\Conf;
Undefined namespace 'RdKafka' 

This is a docker forum and your problem is related to PHP. You probably need to read some more docs…

BUT make sure rdkafka is well installed !

You are running container ans once in a console you are thus (from what I understand) installing the extension by hand.

Are you then running your php code in the exact same container ?

What you should understand when you installing things by hand in a container is it’s not permanent. When you’ll suit the container you’ll loose your manual changes.

To make installation persistent, it should be installed using a dockerfile (my previous link).

sure


yes, i understand

thanks for the answer