PHP requirements

Last updated on
17 January 2024

This documentation needs review. See "Help improve this page" in the sidebar.

Some individual modules may have specific requirements for PHP extensions and configurations beyond those listed below, so, please check the module's documentation as well.

See Drupal 7 PHP requirements for information about Drupal 7.

PHP versions supported

PHP version Drupal version
9.5 10.0 10.1 10.2 11.0
7.3 ⚠️ No
(notes)
❌ No ❌ No ❌ No ❌ No
7.4 ⚠️ No
(notes)
❌ No ❌ No ❌ No ❌ No
8.0 ✅ Yes ❌ No ❌ No ❌ No ❌ No
8.1 (notes) ✅ Yes ✅ Yes ✅ Yes ✅ Yes ❌ No
8.2 ❌ No
(notes)
✅ Yes ✅ Yes ✅ Yes ❌ No
8.3 ❌ No ❌ No ❌ No ✅ Yes ✅ Yes
  1. Drupal 10 requires at least PHP 8.1. PHP 8.1.6 is recommended.
  2. Drupal 9.4 dropped official support for PHP 7.3, and Drupal 9.4 and above automatically drop support for PHP versions no longer supported by the PHP maintainers. Drupal 9 sites on PHP 7.3 and PHP 7.4 may still be installed and updated to the next minor version (with a warning), but their security coverage is not guaranteed unless they update to a supported PHP version.
  3. Drupal 9 uses syntax that still works but is deprecated in PHP 8.2. These errors are suppressed from 9.5.10 to allow to update to PHP 8.2 before updating to Drupal 10.

What does it mean for a PHP version to be supported? What does it mean for the PHP installation to be "too old"?

Drupal minor versions receive a predefined window of security coverage (typically 12 months) as long as a supported PHP version is used. 

We prefer to allow sites to receive security updates even if they are using a version of PHP that is no longer supported. However, Drupal's upstream dependencies may drop support for older PHP versions before the Drupal major version reaches its end of life. If this happens, the Drupal site will no longer be able to install security updates for that dependency, so we can no longer guarantee its security coverage.

Site owners will receive warnings on their site status report that their PHP installation is "too old" if the site's PHP version is old enough that a dependency is likely to drop support for it.

If a dependency does drop support for a PHP version that was initially supported by the Drupal major version, an unscheduled minor release may be created to require the new PHP and dependency versions. For example, Drupal 9.0.0 supported PHP 7.3, so if a Drupal 9 dependency drops support for PHP 7.3 before Drupal 9's end-of-life date in November 2023, we may create a new minor version outside the normal schedule that increases the PHP version requirement to 7.4 and the dependency's version requirement to the supported version.

Drupal will work on all supported PHP versions. Recommended PHP versions are the best choice for building a Drupal site because they will remain supported longer.

PHP extensions needed

Extensions used by Drupal core are defined in Core's composer.json file - see for example the file for Drupal 9.1.x. Look at the "require" section and the keys starting with "ext-".

Note: Adding a PHP extension to your system, at least on Linux (and Mac), means finding and installing the relevant PHP package using your package manager. Typically the package name for the Foo extension is named "php-foo" or "php7-foo", but this isn't always the case. Some extensions are part of the core PHP package and hence are enabled by default. 

Database extensions

The PHP Data Objects (PDO) extension must be activated for Drupal 9 and higher to install and run correctly. The PECL version of PDO is not compatible with Drupal 9 and cannot be used. In addition, a PHP extension for connecting to your chosen database must be installed and enabled.

Drupal's currently supported database connectors are SQLite, mysql (the original MySQL extension), mysqli (an improved connector for newer MySQL installations), and pgsql (for PostgreSQL).

XML extension

PHP XML extension (for Blog API, Drupal, and Ping modules). This extension is enabled by default in a standard PHP installation; the Windows version of PHP has built-in support for this extension. Enabling the XML extension also enables PHP DOM. DOM is now a systems requirement.

Image library

An image library for PHP such as the GD library is a required extension in Drupal 9 and higher, and is needed for image manipulation (resizing user pictures, image and image cache modules). ImageMagick is also supported for basic image manipulations in Drupal core but there is much less support from contributed modules.

OpenSSL

The PHP OpenSSL extension is recommended to allow Drupal to make outgoing requests using HTTPS and is required when using the Update Manager. Read PHP OpenSSL requirements for more information.

JSON

Drupal 9 and higher require PHP compiled with JSON. JSON support is normally compiled as part of PHP core, but in case you're getting errors like PHP Fatal error: Call to undefined function Drupal\\Component\\Serialization\\json_encode() in ... core/lib/Drupal/Component/Serialization/Json.php try adding the JSON extension.

cURL

The PHP cURL extension is required for automated testing in Drupal 9 and higher, as well as Aggregator and some contributed modules. Many Linux distributions and development stacks will have it enabled by default, but if your system doesn't either enable it in php.ini (typically on Windows) or install it using your package manager (typically on Linux).

Mbstring

The PHP mbstring extension provides multibyte specific string functions used for Drupal installation in other languages except for English and also multilingual sites in Drupal. It helps deal with multibyte encodings in PHP and also handles Unicode based encoding like UTF-8 or UCS-2.

PHP configuration settings

Memory requirements

PHP memory requirements can vary significantly depending on the modules in use on your site. The minimum required memory size is 64MB.

Warning messages will be shown if the PHP configuration does not meet these requirements. However, while these values may be sufficient for a default Drupal installation, a production site with a number of commonly used modules enabled could require more memory. Typically 128 MB or 256 MB are found in production systems. Some installations may require much more, especially with media-rich implementations. If you are using a hosting service it is important to verify that your host can provide sufficient memory for the set of modules you are deploying or may deploy in the future. (See the Increase PHP memory limit page in the Troubleshooting FAQ for additional information on modifying the PHP memory limit.)

.htaccess settings

Some of the memory settings are contained in the default .htaccess file that ships with Drupal, so you shouldn't need to set them explicitly. Note, however, that setting PHP configuration options from .htaccess only works under the following conditions:

  • With Apache (or a compatible webserver)
  • If the .htaccess file is actually read, i.e. AllowOverride All in the main Apache configuration (usually httpd.conf) is enabled
  • If PHP is installed as an Apache module

In some shared hosting environments, access to these settings is restricted. If you cannot make these changes yourself, please ask your hosting provider to adjust them for you.

Other interfaces

See the PHP manual for how to change configuration settings for other interfaces to PHP.

Xdebug

If using Xdebug:

Setting: xdebug.show_exception_trace = 0
Reason: Could cause Drupal's installer to crash.

Using Xdebug with Drupal 9:

Setting: xdebug.collect_params = ?
Reason: Setting xdebug.collect_params too high will prevent Drupal 9 from installing and working properly.

Setting: xdebug.max_nesting_level = 256
Reason: Using the default max_nesting_level of 100 (in xdebug versions < 2.3) causes some pages to crash.

Note: From version 3.0 an onwards, xdebug.collect_params Has been removed. Arguments are now always visible with variable contents and argument name

PHP from different sources

Drupal is designed to work with PHP as distributed on PHP.net. Every effort is made to make it work with PHP versions from other sources but this is only done on a best effort basis. In particular, Suhosin is known to break certain features; and some operating systems move core components into other packages.

PHP requirements details

See the phpinfo() page on Drupal.org to learn how to use Phpinfo to get the details of your system. For example, Phpinfo will tell you if you have a database already installed and what versions of PHP, MySQL, etc. your system is running. Phpinfo will also tell you what PHP variables are set as well as many other helpful things.

It is often possible to update to a newer version of PHP that ships with your Linux distribution. Please read the documentation for your Linux distribution.

Some notable points

  • Be aware of the limitations of 32-bit PHP.
  • The Drupal 9 Update manager can install/update modules and themes via SSH if the required libraries have been installed on the server. (On Debian the package is named "libssh2-php".)
  • If the native opcache is enabled, settings opcache.save_comments must be enabled (set to 1 which is the default), otherwise Annotations will not be saved/loaded. 

Install PHP 8.2 packages

Installing the packages of the currently supported and recommended release PHP 8.2 as root on a Debian flavor server should set you up for Drupal 10:

sudo apt install php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-gd php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-sqlite3 php8.2-xml php8.2-zip php8.2-apcu

Remember to restart the server, for it to take effect.

Help improve this page

Page status: Needs review

You can: