Skip to content
Latchkey

PHP "Call to undefined function" (missing extension) in CI

When code calls a built-in function provided by a PHP extension (mb_*, intl, gd, bcmath) and that extension is not loaded, PHP raises "Call to undefined function". In CI this means the extension was never enabled in the runner’s PHP build.

What this error means

A PHP step fails with "PHP Fatal error: Uncaught Error: Call to undefined function mb_strlen()" (or bcadd, imagecreate, etc.). The function is fine locally where the extension is enabled.

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

Common causes

The extension providing the function is not enabled

mb_strlen needs ext-mbstring, bcadd needs ext-bcmath, imagecreate needs ext-gd. If the extension is off in CI, the function is undefined.

A different PHP build is used in CI than locally

The CI PHP was compiled or configured without the extension your code depends on.

How to fix it

Enable the extension in CI

Add the required extension to the PHP setup step.

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

Declare the requirement in composer.json

Add the ext-* requirement so Composer fails early and clearly when the extension is missing.

composer.json
{
  "require": {
    "ext-mbstring": "*"
  }
}

How to prevent it

  • Declare every ext-* your code uses in composer.json require.
  • Enable the same extensions in CI that you run in production.
  • Match the CI PHP build to your deploy target.

Related guides

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