Customization

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 extensions

What 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.

View the supported extensions

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 deployment

Preparing your Dockerfile

Our images are unprivileged by default. This means you'll need to switch to root to do "root things", then switch back to the www-data user. This ensures your container image is hardened against security vulnerabilities.
Dockerfile
# 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.

Dockerfile
# 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:

We use the --build flag to tell Docker to rebuild the image from scratch. Good practice in development if you're making changes to your Dockerfile.
Terminal
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 production

Common PHP extensions that you might need

We compiled a list of extensions for you to reference.

ExtensionDescriptionWhy it's not included by default
intlInternationalization 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.
Don't see the extension you need? Having trouble? Open a discussion on GitHub →