PHP 8.0 and Drupal 9

By nguyen.phan, 29 November, 2020
PHP 8 and Drupal 9

PHP 8 released:

PHP 8 was released on 26 November 2020. It is a major update of the PHP language, which mean that: "It contains many new features and optimizations including named arguments, union types, attributes, constructor property promotion, match expression, nullsafe operator, JIT, and improvements in the type system, error handling, and consistency."[1][2]

Drupal 9 and PHP 8.0:

In the previous article, I introduced my systems Drupal 9 on Apache, Nginx, PHP 7. As you know, from version 9.1.0 Drupal is fully compatible with PHP 8.0! [3]

To take advantage of  the strength of the PHP ecosystem, and testing  for compatibility of Drupal 9, I upgrade PHP version 7.4 to PHP version 8.0.

Drupal 9 system information
Drupal 9 System information

One of the new features of PHP 8 is JIT - just in time. It was introduced in PHP 7.4 as an experimental feature and disabled by default. As announced, PHP JIT promises performance improvements. 

Enable JIT on PHP 8

  • opcache.jit_buffer_size - size of shared memory buffer reserved for native code generation (in bytes; K, M - suffixes are supported). Default - 0 disables JIT.
  • opcache.jit - JIT control options. Consists of 4 decimal digits - CRTO (Default 1205. Probably, better to change to 1235).

opcache.enable=1 opcache.jit_buffer_size=100M opcache.jit=1255

JIT status
JIT enabled
Lighthouse report
Lighthouse tool report on Chrome

Conclusion:

With many changes, as well as many features and performance improvements, we can expect breakthroughs in the PHP language. However,  we may need to make changes to the source code to ensure compatibility.

References:

  1.  PHP 8 Release www.php.net
  2.  PHP 8.0 wiki.php.net
  3.  Drupal 9.1.0-rc2 www.drupal.org