This is an old revision of the document!

PHP RFC: Allow loading extensions by name


This RFC proposes a portable way to configure the list of PHP extensions to load.

Today, 'extension=' and 'zend_extension=' lines in php.ini must contain the extension's file name. Unfortunately, this file name depends on the platform PHP is running on. The situation is still worse on WIndows, where a 'php_' prefix must be added.

While seasoned PHP administrators are used to this mechanism, the issue remains when writing documentation, platform-agnostic scripts and, more generally, in every case where a unified syntax would allow using the same configuration file in different environments. The typical example is the coexistence of a Windows development environment and a Linux production. In this case, it is currently impossible to write a single configuration file that will work in both environments, forcing developers to manually maintain two separate versions of the file.

The issue is rather easy to solve because the logic to compute the file name corresponding to a given extension is well-known and easy to implement.


This RFC allows to load PHP and Zend extensions using the extension name instead of the file name. File names remain supported as before.

Example :


'extension=bz2', for example, will cause PHP to load a file named 'php_bz2.dll' on Windows, or a file named 'bz2.so' on Linux.

Example php.ini files will be modified because loading extensions by name becomes the recommended way of configuring additional extensions to load. File names remain supported and considered as legacy.

Cases where the extension name is accepted :

  1. 'extension=' INI setting
  2. 'zend_extension=' INI setting
  3. argument to the dl() function

Cases where the extension name cannot be used :

  1. The '-z' CLI option still requires an absolute file path.
  2. When specifying an absolute path, a filename must be provided. A line like 'extension=/path/to/extensions/bz2' is invalid.

Backward Incompatible Changes

None, as file names remain supported.

Proposed PHP Version(s)


RFC Impact



To Existing Extensions


To Opcache


New Constants


Open Issues

This RFC does not pretend solving every difference that may exist between Windows and Unix configurations. Where paths are set, the differences will remain. It allows to unify the configuration in the frequent cases where the only difference is the 'extension=/zend_extension=' lines.

Unaffected PHP Functionality

The '-z' CLI option does not support extension names.

Future Scope

As it is possible to distinguish between PHP and Zend extensions at load time, the 'zend_extension=' keyword could be suppressed in favor of a single 'extension='. This is left for the future because specific constraints (like loading Zend extensions always before PHP ones) make it quite complex to implement.

Proposed Voting Choices

This RFC requires a 50%+1 majority.

Patches and Tests


After the project is implemented, this section should contain

  1. the version(s) it was merged to
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature


Rejected Features

Keep this updated with features that were discussed on the mail lists.

rfc/load-ext-by-name.1462884853.txt.gz · Last modified: 2017/09/22 13:28 (external edit)