PHP RFC: Allow loading extensions by name


This RFC proposes a unified 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, the filename depends on the platform PHP is running on :

  1. On Unix-like environments, the file name has the form '<extension-name>.<suffix>'. <suffix> is 'so' on every system, except HP-UX, where it is 'sl'.
  2. On Windows, the file name has the form 'php_<extension-name>.dll'.

While seasoned PHP administrators are used to this mechanism, this is a real issue for newcomers.

Under Unix/Linux, the typical mistake is to uncomment an 'extension=php_xxx.dll' line in the php.ini file.

On Windows, the situation for newcomers is still more confusing, as the distributed 'php.ini' files wrongly state that the Windows syntax is 'extension=modulename.extension', giving the wrong example of 'extension=mysqli.dll'. Ten lines below, the '.ini' file contains the right ';extension=php_mysql.dll' syntax but these conflicting directives are very confusing.

The issue may also appear when writing documentation and platform-agnostic scripts.

To summarize, I think that a unified syntax to enable extensions on every environment would make the life easier for a lot of people, especially those coming to PHP.

The issue is quite easy to solve because the logic to compute the file name from an extension name is well-known.


This RFC proposes an extension to the mechanism used to load PHP and Zend extensions. In addition to file names, it adds support for bare extension name. Note that the current syntax, using file names, remains supported as before.

Example :


'extension=bz2', for example, will cause PHP to load a file named 'php_bz2.dll' on Windows, a file named 'bz2.so' on Linux, and a file named 'bz2.sl' on HP-UX.

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

Cases where the extension name is accepted :

  1. 'extension=' INI setting
  2. 'zend_extension=' INI setting
  3. as 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 mixing a specific directory with an extension name, 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 '.ini' configuration files.

Unaffected PHP Functionality

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

Proposed Voting Choices

This RFC requires a 50%+1 majority.

Vote is now closed. RFC is approved for inclusion in 7.2.

Allow loading extensions by name
Real name Yes No
ab (ab)  
ashnazg (ashnazg)  
bishop (bishop)  
bukka (bukka)  
bwoebi (bwoebi)  
colinodell (colinodell)  
davey (davey)  
derick (derick)  
dm (dm)  
emir (emir)  
francois (francois)  
galvao (galvao)  
kelunik (kelunik)  
krakjoe (krakjoe)  
lcobucci (lcobucci)  
mrook (mrook)  
pollita (pollita)  
sammyk (sammyk)  
tpunt (tpunt)  
trowski (trowski)  
zeev (zeev)  
Final result: 17 4
This poll has been closed.

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.txt · Last modified: 2018/03/01 23:23 by carusogabriel