mysqli extension #202286
Replies: 5 comments
-
|
First, check which PHP executable you're actually using: which php
php -v
php --iniIf php -i | grep extension_dir
ls $(php -i | awk -F'=> ' '/extension_dir/ {print $2}') | grep mysqliIf the extension is missing entirely, you'll need to install/rebuild it for the PHP version inside your Codespace rather than installing Could you also share:
That should make it easier to identify why |
Beta Was this translation helpful? Give feedback.
-
|
It looks like First, check which PHP installation is active: which php
php -v
php --ini
command -v docker-php-ext-installIf Create # Keep the same PHP image/version currently used by your devcontainer
FROM mcr.microsoft.com/devcontainers/php:4-8.3-bookworm
RUN docker-php-ext-install mysqli pdo_mysqlThen update {
"name": "PHP",
"build": {
"dockerfile": "Dockerfile"
}
}Replace the image version above with the PHP version your project requires. After saving the files, open the VS Code Command Palette and run: Then verify the extension: php -m | grep -Ei 'mysqli|pdo_mysql'
php -r 'var_dump(class_exists("mysqli"));'The second command should output: The reason Could you also share the output of these commands if it still fails? which php
php -v
php --ini |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
It sounds like I'd start by checking: which php
php -v
php --ini
php -m | grep mysqli |
Beta Was this translation helpful? Give feedback.
-
|
Enabling mysqli in PHP on GitHub Codespaces
php --ini shows your loaded php.ini path and the "Scan for additional .ini files" directory (usually /etc/php/8.x/cli/conf.d/). Codespaces sometimes has more than one PHP install, so make sure you're targeting the right version. (Replace 8.x with your actual version, e.g. php8.2-mysqli.) Then check the conf.d directory (from step 1) for a file like 20-mysqli.ini containing extension=mysqli. If it's missing or empty, the enable step didn't complete. 6.. Make it permanent |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
Body
Hi
I'm struggling to enable mysqli in VSC on Codespaces. Running this code "php -m | grep mysqli" does not output anything, which means the mysqli extension is not enabled.
I've tried various methods (incl. sudo apt-get update && sudo apt-get install -y php-mysqli), however it does not seem to enable mysqli. I keep getting an error "PHP Fatal error: Uncaught Error: Class "mysqli" not found".
Any help is much appreciated
Beta Was this translation helpful? Give feedback.
All reactions