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.
PHP Fatal error: Uncaught Error: Call to undefined function
mb_strlen() in /app/src/Text.php:14Common 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.
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, bcmath, gdDeclare the requirement in composer.json
Add the ext-* requirement so Composer fails early and clearly when the extension is missing.
{
"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.