php-docker icon indicating copy to clipboard operation
php-docker copied to clipboard

Error when I ran docker-compose up

Open mraghbeerasi opened this issue 2 years ago • 2 comments

I received the following error when I ran docker-compose up. Can you share your thoughts:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3

mraghbeerasi avatar Jan 28 '23 02:01 mraghbeerasi

same me

agt2020 avatar Jun 05 '23 11:06 agt2020

Hi, so I figured it out!

1st: Go to the Docker desktop application and click on the specific Apache service or image you used for your project (in my case, I used PHP:8.3.0-apache) 2nd: Right-click on the three vertical dots on Actions and click on Open in Terminal 3rd: Run this command docker-php-ext-install mysqli in that terminal (this will install my SQL package needed) 4th: Return to Docker Desktop and restart that specific container, and that should work!

PS: The only issue I found is that when I run the docker-compose-up command, I must complete this whole process again for my site to run. In other words, the mysqli packages do not save. I am testing on my end, but please share if anyone knows another way!

Look at Vincent Stevenson's tutorial on YouTube; this is where I found the solution!

croman10 avatar Dec 05 '23 01:12 croman10