This is an old revision of the document!
PHP RFC: Allow loading extensions by name
- Version: 1.0
- Date: 2016-05-10
- Author: François Laupretre francois@php.net
- Status: Under Discussion
- First Published at: http://wiki.php.net/rfc/load-ext-by-name
Introduction
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.
Proposal
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 zend_extension=xdebug
'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 :
- 'extension=' INI setting
- 'zend_extension=' INI setting
- argument to the dl() function
Cases where the extension name cannot be used :
- The '-z' CLI option still requires an absolute file path.
- 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)
7.1
RFC Impact
To SAPIs
None
To Existing Extensions
None
To Opcache
None
New Constants
None
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
Pull request (final) : https://github.com/php/php-src/pull/1741
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged to
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
References
Rejected Features
Keep this updated with features that were discussed on the mail lists.