November 2021 and on cimg/PHP Changes

Hey Everyone!

For anyone using the cimg/php Convenience Images, I wanted to share a change on how PHP is made available in the images. We use to use an Ubuntu PPA to install the PHP versions. This means PHP itself and many extension were (and could be) installed via apt-get. Starting with November releases, this has changed.

Now in cimg/php the PHP version is compiled into the image itself from source. There were a few reasons for this change but ultimately, this will allow CircleCI to better maintain these images moving forward. For some people, this change won’t mean much. What’s very different is how extensions are handled.

Many, many extensions are now pre-installed by default when we compile PHP. For anything that you still need to install, you won’t use apt-get anymore. Instead, you’ll want to use PEAR/PECL. Please see the readme for more information.

What about extensions that are not in PECL?

Specifically my project requires ext-ftp but it is not enabled in cimg/php:8.1.2, and there does not seem to be a way for me to enable it? Thus composer install fails with:

Root composer.json requires PHP extension ext-ftp * but it is missing from your system. Install or enable PHP's ftp extension.

Any ideas on how to proceed?

2 Likes

You can also use mlocati/docker-php-extension-installer.

So when you had this in the old image:

sudo docker-php-ext-install gd mbstring mysqli pdo pdo_mysql

It now becomes that:

curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
sudo install-php-extensions gd mbstring mysqli pdo pdo_mysql