PHP 8.5: CLI/CGI: -z / --zend-extension option removed

Version8.5
TypeRemoval

Prior to PHP 8.5, the help output of the PHP executable (php --help / php -h) noted that it supports a -z option to load a Zend extension prior to executing a given file or starting the interpreter.

php --help
Usage: php [options] [-f] <file> [--] [args...]
   php [options] -r <code> [--] [args...]
   php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
   php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
   php [options] -S <addr>:<port> [-t docroot] [router]
   php [options] -- [args...]
   php [options] -a

  -a               Run as interactive shell (requires readline extension)
...
  -z <file>        Load Zend extension <file>
...

The -z option also has a longer alias --zend-extension.

In PHP 8.5, both -z and --zend-extension options are removed, because they are non-functional across all PHP versions. When the -z / --zend-extension option is passed, it simply does not load the Zend extension, and emits no warnings or any additional notices:

For example, the following -z option value is supposed to load the Opcache extension (named opcache.so here), but the extension is not listed in the list (output of the -m option).

php -z /usr/lib/php/20240924/opcache.so -m

Recommended Replacement

Existing applications that use the -z or the --zend-extension on the php executable can remove the option and the value for identical behavior. Because this option did not actually load the Zend extension, simply not passing this option brings the identical behavior.

Applications that need to load a Zend extension before executing can use the -d option that sets PHP INI values. Note that the -d option can be used any number of times to set multiple INI values.

The example below shows how to load Xdebug extension:

- php -z xdebug.so my-script.php
+ php -d zend_extension=xdebug.so my-script.php

The -d option-based alternative is compatible across all PHP versions, including PHP 8.5.


Discussion Implementation