Skip to content
Latchkey

PHP "Call to undefined function" - Missing Extension in CI

PHP tried to call a function that is not defined in this runtime. Most often the function belongs to an extension that is not enabled on the CI runner (e.g. mb_* from mbstring, curl_* from curl, intl functions).

What this error means

A script fails with "Call to undefined function <name>()". The same code runs locally because your local PHP has the extension enabled, but the runner’s PHP does not.

PHP error
PHP Fatal error:  Uncaught Error: Call to undefined function mb_strlen() in
/app/src/Text.php:15

Common causes

The providing extension is not enabled

mb_strlen needs mbstring, curl_init needs curl, json_encode needs json, Normalizer/intl_* need intl. If the extension is missing, the function is undefined.

A package function not autoloaded

Global helper functions from a package require its files autoload entry. If Composer’s autoloader was not generated, those functions are undefined.

How to fix it

Enable the extension on the runner

.github/workflows/ci.yml
- uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: mbstring, intl, curl, json

Confirm which functions/extensions are loaded

  1. Run php -m to list loaded extensions.
  2. Run php -r "var_dump(function_exists('mb_strlen'));" to test a specific function.
  3. If it is a package helper, run composer dump-autoload so files autoloads register.

How to prevent it

  • Enable every required extension in CI via setup-php to mirror production.
  • Assert critical functions exist early in the job (php -m).
  • Declare extension requirements (ext-*) in composer.json so Composer fails loudly.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →