Installing PHP extensions
serversideup/php includes the install-php-extensions tool by default. This tool allows you to install almost any PHP module that you'll need.
Default extensions
By default, we include a number of PHP extensions to get you up and running. You can learn more why we have certain defaults and what's all included on our default configurations page.
Learn more about default extensionsWhat extensions are supported?
Since we're using install-php-extensions, we have a wide support of extensions across many versions of PHP. You can find the full list of supported extensions on the project's README.
Installing extensions
Once you have your extensions ready for installation, you need to use root permissions to install them. In most cases, the best experience is to use a Dockerfile to do this while you package your application in a container.
If you're not familiar with the concept of packaging your application for deployment, we recommend you to read our guide on how to do it.
Learn more about packaging your application for deploymentPreparing your Dockerfile
root to do "root things", then switch back to the www-data user. This ensures your container image is hardened against security vulnerabilities.# Choose our base image
FROM serversideup/php:8.4-fpm-nginx
# Switch to root so we can do root things
USER root
# Install the intl and bcmath extensions with root permissions
RUN install-php-extensions intl bcmath
# Drop back to our unprivileged user
USER www-data
Building images with Docker Compose
Here's a simple example with Docker Compose that builds an image with the intl and bcmath extensions.
# Choose our base image
FROM serversideup/php:8.4-fpm-nginx
# Switch to root so we can do root things
USER root
# Install the intl and bcmath extensions with root permissions
RUN install-php-extensions intl bcmath
# Drop back to our unprivileged user
USER www-data
Once we have our project ready, we can bring our container up with:
--build flag to tell Docker to rebuild the image from scratch. Good practice in development if you're making changes to your Dockerfile.docker compose up --build
Real-life example showing development to production
If you're looking for a more realistic example how this looks from development to production, check out our guide below.
Learn more about development to productionCommon PHP extensions that you might need
We compiled a list of extensions for you to reference.
| Extension | Description | Why it's not included by default |
|---|---|---|
| intl | Internationalization functions, used by Laravel for validating emails with "DNS" or "spoof" validation. | Our tests showed this module will add about 40 MB of space to the Docker image, so we decided to not include it by default. |