If your Laravel Dockerfile starts with FROM php:8-fpm or FROM php:fpm, it will probably break the day PHP 8.6 ships. The official PHP 8.6 Docker images no longer include the pecl command, and they no longer compile mbstring in by default. Laravel needs mbstring, and most Laravel images install Redis or APCu through PECL.
This isn’t just a Docker quirk. PECL itself is being retired in favour of PIE, the PHP Installer for Extensions. This post covers what changed, how to check whether you’re affected, how PIE works, and a production Dockerfile for Laravel on PHP 8.6 that builds cleanly.
What changed in the PHP 8.6 Docker images
- No
peclorpear. A Docker maintainer confirmed in docker-library/php issue #1682 that removingpeclfrom the 8.6 images is intentional, and “this time it’s for keeps”. AnyRUN pecl install ...line fails with/bin/sh: 1: pecl: not found. - No built-in mbstring. Anything that calls an
mb_*function fails withCall to undefined function mb_strlen()unless you build the extension or load a polyfill. Laravel’sStrhelpers use mbstring heavily. - Floating tags move on release day.
php:latest,php:8,php:fpm,php:alpineandphp:8-fpmall point to 8.6 once it’s GA. Minor-pinned tags such asphp:8.5-fpmand digest-pinned images don’t move.
One report also says the 8.6 images are thread-safe (ZTS) builds. I haven’t confirmed that against the final images, so check yours with docker run --rm php:8.6-fpm php -i | grep "Thread Safety".
Why: PECL is being sunset
- A 2025 RFC recommended PIE and deprecated PECL in messaging.
- A new RFC proposes making pecl.php.net read-only on June 30, 2027 and shutting it down on December 31, 2029, with brownouts before that.
The Docker images are just early. Whatever runs your PHP (containers, servers, laptops), the switch is coming.
Check whether your project is affected
Run this from your project root:
grep -rniE "FROM +php:|pecl |pear " --include="Dockerfile*" --include="*.yml" --include="*.yaml" . \ | grep -v vendor | grep -v node_modules You’re affected if you see a FROM php: line that doesn’t pin a minor version (or already says 8.6), or any pecl install line. The grep misses ARG-based tags (FROM php:${PHP_VERSION}-fpm), so check those too. Then check whether something already supplies mbstring:
composer show symfony/polyfill-mbstring If the polyfill is installed, simple mb_* calls keep working, just slower. Don’t rely on it in production.
The quick fix: pin to PHP 8.5
If a deploy is failing right now, pin the minor version and move on:
FROM php:8.5-fpm This is the right call until your extensions support 8.6. As of late October 2026, apcu 5.1.28 and phpredis 6.3.0 didn’t compile against 8.6; both projects had merged fixes but not tagged releases. A floating php:fpm tag means your production PHP version changes without a commit, so pin regardless.
Fix 1: build mbstring yourself
mbstring needs the Oniguruma headers. On Debian-based images:
RUN apt-get update \ && apt-get install -y --no-install-recommends libonig-dev \ && docker-php-ext-install mbstring \ && rm -rf /var/lib/apt/lists/* On Alpine:
RUN apk add --no-cache oniguruma-dev \ && docker-php-ext-install mbstring Skip libonig-dev and the build fails with Package requirements (oniguruma) were not met.
Fix 2: replace pecl with PIE
What PIE is
PIE is maintained by the PHP Foundation and works like Composer for extensions. Extensions are published as packages on Packagist, and PIE downloads, builds and enables them for the PHP installation you point it at.
It replaces PECL only for third-party extensions like Redis, Imagick, Xdebug or Swoole. Extensions bundled with PHP (mbstring, intl, pdo_mysql) are still installed the usual way, with docker-php-ext-install.
PIE in a Dockerfile
PIE publishes an image containing only the binary, so you can copy it in:
COPY --from=ghcr.io/php/pie:bin /pie /usr/bin/pie RUN apt-get update \ && apt-get install -y --no-install-recommends unzip $PHPIZE_DEPS \ && pie install phpredis/phpredis \ && pie install apcu/apcu \ && apt-get purge -y --auto-remove $PHPIZE_DEPS \ && rm -rf /var/lib/apt/lists/* Note unzip: minimal images don’t include it, and PIE needs it when an extension publishes prebuilt binaries.
PIE on a server or laptop
curl -fL -o /usr/local/bin/pie \ https://github.com/php/pie/releases/latest/download/pie.phar chmod +x /usr/local/bin/pie pie check-build-tools # PIE 1.5: checks compiler, make, phpize pie search redis # find the Packagist package name pie install phpredis/phpredis pie upgrade # update PIE-installed extensions On macOS, brew install pie works too. Extensions use Packagist names (phpredis/phpredis, not redis).
The PIE 1.5 change that breaks CI
If your composer.json requires extensions ("ext-redis": "*"), pie install with no package name installs the missing ones. Before 1.5, CI passed --allow-non-interactive-project-install and let PIE pick a package for each. In 1.5 that flag is ignored, and an unattended install with no package choice fails. Name the package explicitly:
pie install --no-interaction --no-dev \ --select redis=phpredis/phpredis That’s a good change: letting an installer guess which package provides ext-redis is how supply-chain incidents start.
The alternative: install-php-extensions
mlocati’s install-php-extensions script installs system libraries for you, which makes it the least painful option for Dockerfiles with many extensions:
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions mbstring intl pdo_mysql zip bcmath gd redis opcache pcntl You need version 2.12.5 or newer for PHP 8.6; older versions fail with Unsupported PHP version: 8.6.
Which to pick? install-php-extensions if you want one line that just works in Docker. PIE if you want the official tool that works the same on servers, laptops and containers.
A production Dockerfile for Laravel on PHP 8.6
A three-stage build: Composer dependencies, frontend assets, then a slim runtime. It assumes PHP-FPM behind Nginx or Caddy in a separate container.
# syntax=docker/dockerfile:1 ############################ # 1. Composer dependencies ############################ FROM composer:2 AS vendor WORKDIR /app COPY composer.json composer.lock ./ RUN composer install \ --no-dev --no-interaction --no-progress \ --no-scripts --prefer-dist --ignore-platform-reqs COPY . . RUN composer dump-autoload --no-dev --optimize --classmap-authoritative ############################ # 2. Frontend assets ############################ FROM node:22-alpine AS assets WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci COPY . . RUN npm run build ############################ # 3. Runtime ############################ FROM php:8.6-fpm AS app # Extensions (mbstring is no longer built in on 8.6) COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions \ mbstring intl pdo_mysql bcmath zip gd exif pcntl opcache redis # Production php.ini + opcache tuning RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" COPY docker/php/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini WORKDIR /var/www/html COPY --chown=www-data:www-data . . COPY --chown=www-data:www-data --from=vendor /app/vendor ./vendor COPY --chown=www-data:www-data --from=assets /app/public/build ./public/build RUN php artisan storage:link || true USER www-data EXPOSE 9000 CMD ["php-fpm"] And docker/php/opcache.ini:
opcache.enable=1 opcache.memory_consumption=256 opcache.interned_strings_buffer=32 opcache.max_accelerated_files=20000 opcache.validate_timestamps=0 A few deliberate choices:
-
--ignore-platform-reqsin the vendor stage. Thecomposer:2image runs its own PHP, which won’t match 8.6. Check platform requirements against the runtime image in CI instead (below). - No
php artisan config:cacheat build time. Environment variables don’t exist yet. Runphp artisan optimizein the entrypoint or deploy step. -
validate_timestamps=0. Code never changes inside a production container. Remember this when you exec in to debug. -
.dockerignorematters. Excludevendor,node_modules,.env,.gitandstorage/logsso you never bake secrets into the image.
Queue workers and the scheduler
Use the same image for every role and change the command:
# docker-compose.yml (excerpt) services: app: image: myapp:latest queue: image: myapp:latest command: php artisan queue:work --tries=3 --max-time=3600 scheduler: image: myapp:latest command: php artisan schedule:work --max-time=3600 restarts each worker hourly, which keeps memory leaks in check. With Horizon, use php artisan horizon instead.
Verify the image in CI
docker run --rm myapp:latest php -v docker run --rm myapp:latest php -m | grep -E "mbstring|redis|intl|pdo_mysql" docker run --rm myapp:latest php artisan about --only=environment To run composer check-platform-reqs --no-dev against the runtime, copy Composer into a CI-only build target (COPY --from=composer:2 /usr/bin/composer /usr/bin/composer). For CI jobs that don’t build images, shivammathur/setup-php handles extensions with an extensions: mbstring, intl, redis line.
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
/bin/sh: 1: pecl: not found | 8.6 images have no pecl | Use PIE or install-php-extensions |
Call to undefined function mb_strlen() | mbstring not built in | docker-php-ext-install mbstring with libonig-dev |
Package requirements (oniguruma) were not met | Missing headers | Install libonig-dev (Debian) or oniguruma-dev (Alpine) |
Unsupported PHP version: 8.6 | Old install-php-extensions | Use 2.12.5 or newer |
| PIE fails in CI with no package chosen | PIE 1.5 ignores the old non-interactive flag | Pass --select ext=vendor/package |
| apcu or redis fails to compile | Extension not yet 8.6-ready | Wait for a release, or pin php:8.5-fpm |
| Extension loads but segfaults | Built against an 8.6 RC (ABI changed late) | Rebuild against 8.6.0 GA |
Migration checklist
- ☐ Pin every
FROM php:line to a minor version. - ☐
grep -rn "pecl install\|allow-non-interactive" .across your repos. - ☐ Replace each
pecl install <ext>withpie install <vendor>/<package>or install-php-extensions. - ☐ Add mbstring to PHP 8.6 images.
- ☐ Install
unzipand build tools where PIE runs. - ☐ Add the image checks above to CI.
FAQ
Why did the PHP Docker images remove pecl?
PEAR and PECL are being phased out in favour of PIE. The Docker maintainers removed pecl from the 8.6 images on purpose and have said it isn’t coming back.
What is PHP PIE?
The PHP Installer for Extensions, maintained by the PHP Foundation. It installs third-party extensions from Packagist, like Composer does for packages, and replaces pecl install.
Do I need mbstring for Laravel?
Yes. Laravel requires mbstring, and the string helpers use it throughout. A polyfill works but is slower.
Should I upgrade my production image to PHP 8.6 on release day?
No. Pin php:8.5-fpm until your extensions have 8.6 releases and your tests pass on 8.6. Then switch to php:8.6-fpm, not a floating tag.
Related posts
- Upgrade Laravel to PHP 8.6: Step-by-Step Guide (2026)
- PHP 8.6 for Laravel Developers: 5 Features Worth Using