PHP extensions in applications

3 min read Updated 20 hours ago

PHP extensions in applications

PHP extensions are additional modules that extend the functionality of your application. You can enable or disable extensions based on your application's requirements.

Available extensions

The following PHP extensions are available for your applications:

  • bcmath - Arbitrary precision mathematics
  • bz2 - Bzip2 compression
  • calendar - Calendar conversion functions
  • exif - Image metadata reading
  • excimer - Performance profiling
  • gd - Image processing and generation
  • gettext - Native language support
  • gmp - GNU multiple precision arithmetic
  • imap - Email access functions
  • imagick - ImageMagick image processing
  • intl - Internationalization functions
  • ldap - Lightweight Directory Access Protocol
  • mbstring - Multibyte string functions
  • memcached - Memcached caching support
  • mongodb - MongoDB database driver
  • opcache - PHP code caching for performance
  • pcntl - Process control functions
  • pgsql - PostgreSQL database functions
  • redis - Redis cache and data store support
  • soap - SOAP web services
  • sockets - Low-level socket functions
  • sqlite3 - SQLite database support
  • tidy - HTML/XML cleaning and repair
  • xml - XML parsing
  • xmlrpc - XML-RPC protocol support
  • xsl - XSL transformations
  • zip - ZIP archive support

Default extensions

Your application's base image includes many commonly used PHP extensions by default. Additional extensions can be enabled through the settings interface.

How to configure extensions

To enable or disable PHP extensions:

  1. Navigate to your application settings
  2. Find the "PHP extensions" section
  3. Check the boxes next to the extensions you want to enable
  4. Uncheck any extensions you want to disable
  5. Click "Save changes"
  6. Deploy your application for the changes to take effect

Extension installation process

When you enable PHP extensions, they are installed during the container build process using the install-php-extensions command. This tool automatically handles dependencies and ensures extensions are properly configured.

Common use cases

Here are some common scenarios where you'll need specific extensions:

  • Image processing: Enable gd or imagick for image manipulation
  • Database connections: Enable pgsql for PostgreSQL or mongodb for MongoDB
  • Caching: Enable redis or memcached for caching support
  • API integrations: Enable soap for SOAP web services or xml for XML processing
  • File compression: Enable zip for ZIP file handling or bz2 for Bzip2 compression
  • Internationalization: Enable intl and mbstring for multi-language support

Performance considerations

While extensions add functionality, keep in mind:

  • Only enable extensions your application actually uses
  • Each extension increases the container image size slightly
  • The opcache extension can significantly improve PHP performance
  • Extensions are loaded on every request, so unused extensions add overhead

Troubleshooting

If your application fails to build after enabling extensions:

  • Check the deployment logs for specific error messages
  • Some extensions may have conflicting dependencies
  • Ensure your PHP version supports the selected extensions
  • Try enabling extensions one at a time to identify issues

Database client tools

When you add database services to your application, the necessary client tools are automatically installed:

  • MySQL service automatically installs mariadb-client
  • PostgreSQL service automatically installs postgresql-client

These tools are useful for running database migrations and other database operations during deployment.