Docker¶
Introduction¶
Phalcon is distributed as a Composer package (phalcon/phalcon), so it does not require a dedicated Docker image or a compiled extension. Any official PHP Docker image can run a Phalcon application. You add Phalcon to your project with Composer, the same way you add any other dependency.
Dockerfile¶
Start from an official PHP image, install the PHP extensions your application needs, add Composer, and let Composer pull in Phalcon as a project dependency:
FROM php:8.3-fpm
# Helper to install PHP extensions
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions pdo_mysql gd intl
# Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY . /app
# Phalcon is installed as a project dependency
RUN composer install --no-dev --optimize-autoloader
If you are adding Phalcon to an existing project, run:
Extensions¶
Phalcon is loosely coupled and does not require additional extensions to load. However, some components rely on PHP extensions to work. For example pdo_mysql / pdo_pgsql for database access, gd or imagick for the Image component, openssl for the Security and Crypt components, and redis or memcached for cache and session adapters. Install only the extensions your application uses, as shown in the install-php-extensions line above.
For the full list of extensions available through this helper, see the docker-php-extension-installer documentation. For other extensions, see the official PHP Docker image documentation.
Credits¶
We want to thank the following people for providing us with tools for building production-ready Docker images: