PHP extensions can be enabled or disabled on-demand in your development environment. This guide covers managing PHP extensions.
Temporarily enable a PHP extension for a running container:
dev php-ext-enable extensionnameTemporarily disable a PHP extension:
dev php-ext-disable extensionnameCheck if an extension is loaded:
dev exec php php -m | grep extensionnameOr check PHP info:
dev php -i | grep extensionnameMost common PHP extensions are pre-installed:
- mbstring - Multibyte string functions
- pdo_mysql - MySQL database support
- gd - Image manipulation
- curl - HTTP requests
- xml - XML parsing
- zip - ZIP archive handling
- intl - Internationalization
- soap - SOAP client/server
- bcmath - Arbitrary precision math
- redis - Redis support
- xdebug - Debugging (see xdebug.md)
- blackfire - Profiling (see configure-blackfire.md)
See all loaded extensions:
dev php -mSee PHP configuration:
dev php -iThe php-ext-enable and php-ext-disable commands make temporary changes:
dev php-ext-enable xdebug
dev exec php php -v # XDebug is loaded
dev restart php
dev exec php php -v # XDebug is goneThis is useful for:
- Testing extensions
- Temporarily enabling debugging
- Performance testing with/without extensions
For permanent changes, customize the PHP container. See customize-docker-containers.md.
Create custom/php/Dockerfile:
FROM php:8.2-fpm
RUN docker-php-ext-install extensionnameThen use a docker-custom.yml to build from your custom Dockerfile.
XDebug is available but not enabled by default for performance. Use the dedicated command:
dev xdebug-consoleSee xdebug.md for complete XDebug setup.
Blackfire requires configuration before use. See configure-blackfire.md.
If an extension isn't available, you have two options:
Create a custom PHP container with the extension. See customize-docker-containers.md.
Install temporarily in a running container:
dev exec php docker-php-ext-install extensionnameNote: This persists only until container rebuild.
Some extensions require configuration files. These go in the PHP configuration directory inside the container.
Example for custom extension config:
dev exec php bash -c 'echo "extension=myext.so" > /usr/local/etc/php/conf.d/myext.ini'List available extensions in the container:
dev exec php ls /usr/local/lib/php/extensions/Check PHP error log:
dev logs phpVerify extension file exists:
dev exec php php --ri extensionnameDifferent PHP versions may have different extensions available. Switch PHP versions and check:
dev php-change php83
dev php -m