In PHP 7.2 and higher the mcrypt extension is no longer available, but my project depends on it. I know that the project shouldn't be using something as ancient as mcrypt, but I don't have any say in this. I know that mcrypt was removed from PHP7.2+ but is still in pecl.
What can I do for this project to support php-mcrypt in 7.2 and higher?
DDEV's docs explain how to do custom PECL extensions, see https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-php-extensions - the mcrypt example is given there. A .ddev/web-build/Dockerfile.mcrypt
might look like this:
ENV extension=mcrypt
SHELL ["/bin/bash", "-c"]
# Install the needed development packages
RUN (apt-get update || true) && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests build-essential php-pear php${DDEV_PHP_VERSION}-dev
# mcrypt happens to require libmcrypt-dev
RUN apt-get install -y libmcrypt-dev
RUN pecl install ${extension}
RUN echo "extension=${extension}.so" > /etc/php/${DDEV_PHP_VERSION}/mods-available/${extension}.ini && chmod 666 /etc/php/${DDEV_PHP_VERSION}/mods-available/${extension}.ini
RUN phpenmod ${extension}
Overall, DDEV supports custom Dockerfiles, so you can add almost anything you want to the web container. See docs.
If you wanted to install a different pecl extension, you might need just a few less packages, but the idea is the same.