Table of Contents
📖 1 minute read
Understanding PHP Database Extension Requirements
Different PHP frameworks and CMSs have specific database extension requirements. Installing pdo_mysql doesn’t automatically give you access to the legacy mysql or mysqli extensions — they’re separate modules.
Check What’s Installed
php -m | grep -i mysql
# Output might show:
pdo_mysql
mysqlnd
Verify Specific Extension Availability
<?php
if (extension_loaded('pdo')) {
echo "PDO: Available\n";
}
if (extension_loaded('mysqli')) {
echo "MySQLi: Available\n";
} else {
echo "MySQLi: MISSING\n";
}
The Legacy Trap
Many legacy applications explicitly check for mysqli or mysql functions, even if PDO is available. When migrating to Docker or upgrading PHP versions, audit your Dockerfile’s docker-php-ext-install list against your framework’s actual requirements, not assumptions.
Example: Some CMS platforms check function_exists('mysqli_connect') during installation, which fails if only pdo_mysql is present.
The Fix
# Add to your Dockerfile
RUN docker-php-ext-install \
pdo_mysql \
mysqli \
# ...other extensions
Don’t assume one database extension covers all use cases. Check the framework’s documentation and test explicitly.
Leave a Reply