Drupal 8 PHP requirements

Last updated on
1 February 2018

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

PHP versions supported 

PHP version Supported? Recommended?
5.5 5.5.9+  No
5.6 Yes  No
7.0 Yes  No
7.1 Yes  Yes
7.2 Yes as of Drupal 8.5.0*  Yes

* Drupal 8.4.4 has one remaining critical bug on PHP 7.2 which has been fixed in Drupal 8.5.0, to be released March, 7 2018.

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 7 also has significant speed and caching improvements.

PHP 5.5 has already reach its official end-of-life, and PHP 5.6 and 7.0 will reach their end-of-life at the end of 2018. (See PHP: supported versions for more information.) Drupal 8 will drop support for PHP 5.5 and 5.6 on March 6, 2019. We recommend updating to at least PHP 7.1 if possible, and ideally PHP 7.2, which is supported as of Drupal 8.5.0 (release date: March 7, 2018).

Why is support being dropped for PHP 5?

  • To minimize disruption for both Drupal users and Drupal developers, Drupal 8's support of PHP 5.5 and PHP 5.6 will end at the same time.
  • PHP 5.6 is no longer receiving active support, which means some bugs that affect Drupal 8 will no longer be fixed. 
  • Numerous Drupal 8 dependencies are already dropping support for these older PHP versions, which may interfere with security updates for those dependencies.
  • Most web hosts already support PHP 7. (You can report information about specific hosts on our tracking issue for PHP 7 hosting).

When will support be dropped for PHP 7.0?

  • Support for PHP 7.0 will continue until at least March 6, 2019. We will post an announcement as soon as the end of PHP 7.0 support has been scheduled.
  • Factors we will consider include host and Drupal 8 dependency support for PHP 7.1+. Help us by reporting whether your host supports PHP 7.1 or 7.2.
  • We recommend Ubuntu LTS users plan to update to Ubuntu 18.04 (to be released April 2018) rather than Ubuntu 16.04 for the best future-compatibility.

Does this affect Drupal 7?

No. Drupal 7 remains compatible with PHP 5.2.4 and higher. A separate announcement will be issued if and when that changes.

PHP configuration settings

Memory requirements

PHP memory requirements can vary significantly depending on the modules in use on your site. 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.)


Note: The commands provided here to install php packages are just sample commands. Please use your system specific commands to install those packages.

Database extensions

The PHP extension for connecting to your chosen database must be installed and enabled. Drupal's currently supported database connectors are: mysql (the original MySQL extension), mysqli (an improved connector for newer MySQL installations), and pgsql (for PostgreSQL). Note: PHP 5.x no longer enables the mysql extension by default. Please read the links above for installing and enabling your chosen connector. 

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 needed for image manipulation (resizing user pictures, image and imagecache modules). GD is included with PHP 4.3 and higher and usually enabled by default. GD is a required extension in Drupal 7 and later. ImageMagick is also supported for basic image manipulations in Drupal core but there is much less support from contributed modules.
If you have administrator rights on a Debian/Ubuntu server, and GD is not already available (see your phpinfo) it can usually be installed by running the following command:
sudo apt-get install php7-gd
or on Redhat/Centos:
sudo yum install php-gd
See the ImageMagick install instructions for your platform if you want that.


The PHP OpenSSL extension is recommended to allow Drupal to make outgoing requests using HTTPS. Some platforms provide a separate OpenSSL package, e.g. php7-openssl.

There is also ongoing work to make Drupal core's Update Manager module check for updates using HTTPS, which would make this an even stronger recommendation or possibly a requirement. See #1538118: Update status does not verify the identity or authenticity of the release history URL and https://groups.drupal.org/node/506128.


Drupal 8 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.


The PHP cURL extension is required for the SimpleTest module in Drupal 8, 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, here are instructions on how to enable it for various platforms are below.



Open C:/xampp/php/php.ini in a text editor.

Uncomment the extension=php_curl.dll line by removing the preceding ";".



Run sudo apt-get update && sudo apt-get install php7-curl.


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

can be installed in Linux systems depending on OS, eg: for Debian based system:


sudo apt-get install php7-mbstring  

php5: mbstring is built in libapache2-mod-php5 package, so you can use this command for installing :

sudo apt-get install libapache2-mod-php5

or on Redhat/Centos:
sudo yum install php7-mbstring

Twig C extension

Drupal 8 now uses Twig as the default PHP templating engine. While Twig is included as part of Drupal core, portions can optionally be compiled and included as a PHP extension to improve performance rendering templates. The status report on your site has a section that will indicate whether the Twig C extension has been loaded. Download and compile the latest stable source code for the Twig C extension using these instructions.


.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 web server)
  • 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.


If using xdebug:

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

Using xdebug with Drupal 8:

Setting: xdebug.collect_params = ?
Reason: Setting xdebug.collect_params too high will prevent Drupal 8 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.

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 than ships with your Linux distribution. For RHEL, we recommend http://iuscommunity.org/Repos, and for Debian, http://www.dotdeb.org/.

On Debian libapache2-mod-php5filter may get installed in preference to libapache2-mod-php5 (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=709027). Unfortunately, the libapache2-mod-php5filter package has a bug which breaks Drupal (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=709023). So, make sure you specify to use the libapache2-mod-php5 package instead.

Some notable points

  • Drupal's Composer-based dependencies are packaged using PHP 5.5.9. If you are using a higher PHP version, you might benefit from issuing a composer update command to get more appropriate versions of Composer-based dependencies.
  • Drupal 8 requires version PHP 5.5.9 or later, with the CURL extension. However, it is recommended to use 7.0 or higher. PHP 5.6 is the latest minor release of PHP and therefore offers extra performance and security. Since 5.6.5 (and 5.5.21) PHP also provides built-in SQL injection protection for mysql databases. PHP 7 is fully tested with Drupal 8 and brings much-improved performance.
  • If your curl library is version 7.35 (the default on some ubuntu distributions), there is a bug that could intermittently affect connectivity with other sites.
  • Drupal 8 can no longer be installed on hosts with the 'magic_quotes_gpc', 'magic_quotes_runtime', or 'safe_mode' PHP ini settings turned on; these settings are deprecated in PHP 5.3 and have no effect anymore in PHP 5.4 and higher.
  • PHP Data Objects (PDO) must be activated for Drupal 8 to install and run correctly. Look in your php.ini. Uncomment (remove the leading semicolon) at line extension=php_pdo.dll, extension=php_pdo_mysql.dll. In Linux, these would be extension=pdo.so and extension=pdo_mysql.so. Some Linux distributions may have these extensions by default in files found in the conf.d folder (Ubuntu 12.04: /etc/php5/conf.d has pdo.ini and pdo_mysql.ini). In Debian jessie, you can turn on the extension by running php5enmod pdo as root. If these lines are not there, you will need to add them. The PECL version of PDO is not compatible with Drupal 8 and cannot be used.
  • The Drupal 8 Update manager can install/update modules and themes via SSH if the required libraries have been installed on the server. If you have administrator rights on a Debian/Ubuntu server, and SSH is not already available (see your phpinfo) it can usually be installed by executing:
    apt-get install libssh2-php.
  • Drupal 8 may require the time parameter (max_execution_time) to be at least 30 seconds.
  • If using the APC opcode cache with Drupal 8, APC 3.1.13 or greater is required. PHP 5.5 has the Zend opcode cache built-in (Opcache).
  • php5-ctype is required.
  • The following PHP requirements list is from Drupal 8.0.0 in \core\modules\system\system.install:
    $required_extensions = array( 'date', 'dom', 'filter', 'gd', 'hash', 'json', 'pcre', 'pdo', 'session', 'SimpleXML', 'SPL', 'tokenizer', 'xml', ); 
  • If the native opcache of PHP 5.5+ is enabled, settings opcache.save_comments and opcache.load_comments must be enabled (set to 1) otherwise Annotations will not be saved/loaded and you will get errors like below :
    Uncaught PHP Exception Doctrine\\Common\\Annotations\\AnnotationException: "[Semantical Error] The class "Drupal\\Core\\Render\\Annotation\\RenderElement" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Drupal\\Core\\Render\\Annotation\\RenderElement". If it is indeed no annotation, then you need to add @IgnoreAnnotation("RenderElement") to the _class_ doc comment of class Drupal\\contextual\\Element\\ContextualLinksPlaceholder." at /srv/www/drupal8/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php line 54 

A shortlist based on above:

Section Drupal 8 requirement
PHP version min 5.5.9 - Rec 5.6.5
core allow_url_fopen must be OFF or nonexistent
core display_errors off
core max_execution_time min 30 seconds
core expose_php must be OFF or nonexistent
core memory_limit 64MB
ctype ctype functions enabled
cURL cURL support enabled (avoid 7.35)
cURL libSSH Version required for install update
date date/time support enabled
dom DOM/XML enabled
fileinfo fileinfo support enabled
filter Input Validation and Filtering enabled
gd GD Support enabled
core magic_quotes_gpc must be OFF or nonexistent
core magic_quotes_runtime must be disabled or nonexistent
core safe_mode must be disabled or nonexistent
core register_globals must be OFF or nonexistent
hash hash support enabled
openssl openssl support enabled
json json support enabled
pcre PCRE (Perl Compatible Regular Expressions) Support enabled
pdo PHP Data Objects(PDO) (specific for your database)
pecl PECL version of PDO not compatible
session Session Support enabled
session session.auto_start 0
session session.cache_limiter nocache
SimpleXML Schema support enabled
SPL SPL support lots
Suhosin APC.include-once-override avoid
Tokenizer Tokenizer Support enabled
XML XML Support enabled
XML XML Namespace Support enabled
Zend OPcache Opcode caching up and running
Zend OPcache PHP 5.5+ opcache.save_comments 1
Zend OPcache PHP 5.5+ opcache.load_comments 1
MODULE TESTING memory_limit 256