phacility/phabricator · error · Exception
About to call new %s, but the PHP MySQLi extension is not av
Error message
About to call new %s, but the PHP MySQLi extension is not available!
What it means
AphrontMySQLiDatabaseConnection::connect() requires ext/mysqli and checks class_exists('mysqli') up front so the failure is explicit instead of a fatal about an undefined class. mysqli ships with PHP but must still be compiled in or loaded as a package/extension; a runtime without it cannot talk to MySQL at all. This check fires before any connection attempt is made.
Source
Thrown at src/infrastructure/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:37
public function getInsertID() {
return $this->requireConnection()->insert_id;
}
public function getAffectedRows() {
return $this->requireConnection()->affected_rows;
}
protected function closeConnection() {
if ($this->connectionOpen) {
$this->requireConnection()->close();
$this->connectionOpen = false;
}
}
protected function connect() {
if (!class_exists('mysqli', false)) {
throw new Exception(pht(
'About to call new %s, but the PHP MySQLi extension is not available!',
'mysqli()'));
}
$user = $this->getConfiguration('user');
$host = $this->getConfiguration('host');
$port = $this->getConfiguration('port');
$database = $this->getConfiguration('database');
$pass = $this->getConfiguration('pass');
if ($pass instanceof PhutilOpaqueEnvelope) {
$pass = $pass->openEnvelope();
}
// If the host is "localhost", the port is ignored and mysqli attempts to
// connect over a socket.
if ($port) {
if ($host === 'localhost' || $host === null) {View on GitHub (pinned to 5720a38cfe)
Solutions
- Install the extension: apt install php-mysqli (or docker-php-ext-install mysqli in official images), or rebuild PHP with --with-mysqli
- Enable it in the php.ini actually loaded by the runtime you use, then restart PHP-FPM / re-run the CLI
- Verify with php -m | grep mysqli (and php --ini to confirm which ini is loaded) for both web and CLI
- Confirm the same runtime selection if cron/daemon contexts fail while web works
Example fix
# before: PHP runtime without mysqli
$ php -r 'var_dump(class_exists("mysqli"));' // false => connect() throws
# after: install and enable, then verify
$ apt install php-mysqli && systemctl restart php8.2-fpm
$ php -m | grep mysqli
mysqli Defensive patterns
Strategy: validation
Validate before calling
// Bootstrap check with an actionable message, before any DB work:
if (!class_exists('mysqli', false)) {
throw new Exception(
'ext/mysqli is not loaded in this PHP SAPI. '.
'Install it (apt install php-mysqli / docker-php-ext-install mysqli), '.
'enable it in the loaded php.ini, and check with: php -m | grep mysqli');
} Prevention
- Include php-mysqli (or compile with --with-mysqli) in every runtime image and package set, web and CLI alike
- Verify with php -m | grep mysqli after provisioning and after PHP upgrades
- Confirm php --ini to make sure the CLI loads the same extensions as FPM
When it happens
Trigger: Running Phabricator on PHP built without mysqli (--disable-mysqli or a minimal compile); slim Docker images (bare php:cli) that exclude extensions; extension installed but not enabled in the CLI/FPM php.ini being used; wrong php.ini loaded after an upgrade.
Common situations: Custom-compiled PHP for performance; minimal container images; distro split packages (php-mysqli not installed); the web SAPI has mysqli but the CLI used for bin/storage does not, or the reverse.
Related errors
- About to call %s, but the PHP MySQL extension is not availab
- Service "%s" is unrecognized, restricted, or you do not have
- When creating a new Almanac interface via the Conduit API, y
- Device "%s" is unrecognized, restricted, or you do not have
- Interfaces must have a unique combination of network, device
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/7b08e008888a5b23.
Report an issue: GitHub.