Table of Contents

Abstract Extension API and Dependency Interface

Details

Abstract

The objective of this project is to develop functionality for PHP that will allow extensions to register a set of functions as a versioned API, since PHP does not currently handle interdependencies among PHP extensions well, which leads to various problems. This would also solve the current problem of extension load order.

Documentation

Versioning

Versions are in the format major.minor[.build[.revision]] in the string representation. These are stored in unsigned integers for ease of searching. The first 8 bits are used for the major, next 8 for the minor, next 8 for the build and the last 8 bits for the revision. It is possible to convert from the string representation to an unsigned integer using zend_eapi_toi and from an unsigned integer to the string format using zend_eapi_toa function.

Macros

EAPI_SET_CALLBACK(ext_name, version, callback) 

Sets a callback - with reference to a extension and a version - should be called during MINIT. The callback will be called after all extensions have been initialized. Callback will be called with a reference to the API of the specified extension. See zend_eapi_set_callback.

ext_name Extension name
version Version - if a null value will is passed the callback will be called with the latest version
callback Function pointer to the callback function
EAPI_SET_EMPTY_CALLBACK(callback) 

Sets an empty callback - should be called during MINIT. The callback will be called after all extensions have been initialized. See zend_eapi_set_empty_callback.

callback Function pointer to the callback function
EAPI_CALLBACK_FUNCTION(callback) 

Defines the callback function. The callback function will be called with the following parameters: type, module_number, api (pointer to the api), ext_name, version,

callback Name of the callback function
EAPI_EMPTY_CALLBACK_FUNCTION(callback) 

Defines the empty callback function. The callback function will be called with the following parameters: typei and module_number,

callback Name of the callback function

Functions

All functions return SUCCESS on success and FAILURE on failure.

int zend_eapi_register(char *ext_name, char * version_text, void *api, size_t size)

Registers an API

ext_name Extension name
version API version in format major.minor[.build[.revision]]
api A ponter to the API structure
size Size of the API structure
int zend_eapi_version_toi(char *version_text, uint *version_int)

Converts a version in text format to an integer.

version_text Version as a string
version_int Version as a numerical value
int zend_eapi_version_toa(uint version, char * version_text)

Converts a version in integer format to a string

version_text Version as a string
version_int Version as a numerical value
int zend_eapi_find_versions(char *ext_name, uint version, uint mask, uint *result, int *size, int buf_length)

Finds the set of versions available. Matches versions if (extension_version & mask) == (version & mask).

ext_name Extension name
version Version to be searched for
mask A mask to specify which part of version should be matched
result Pointer to an array, which will be filled with matched versions
size Number of matches found
buf_length Capacity of the array results (memory allocated)
int zend_eapi_get_latest_version(char *ext_name, uint *version)

Gives the latest version of the extension available

ext_name Extension name
version Latest version as a numerical value
int zend_eapi_exists(char *ext_name, char *version)

Checks if the API is available

ext_name Extension name
version Version
int zend_eapi_get(char *ext_name, char *version, void **api)

Retrieves the API

ext_name Extension name
version Version
api API will be loaded here if it is available
int zend_eapi_set_empty_callback(int type, int module_number, void (*callback)(EMPTY_CALLBACK_FUNC_ARGS))

Sets an empty callback - should be called during MINIT. The callback will be called after all extensions have been initialized. Use EAPI_SET_EMPTY_CALLBACK.

callback Function pointer to the callback function
int zend_eapi_set_callback(int type, int module_number, char *ext_name, char *version, void (*callback_func)(CALLBACK_FUNC_ARGS))

Sets a callback - with reference to a extension and a version - should be called during MINIT. The callback will be called after all extensions have been initialized. Callback will be called with a reference to the API of the specified extension. Use EAPI_SET_CALLBACK.

ext_name Extension name
version Version - if a null value will is passed the callback will be called with the latest version
callback Function pointer to the callback function

Timeline

20th April to 23rd May – Community bonding period

23rd May to 1st July – Implementing most important features

1st July to 10th July – Testing the implemented section

10th July to 1st August – Completing the implementation of all features

1st August to 4th August – Buffer

4th August to 17th August – Testing

Progress

12th May
15th May
23rd May
31st May
5th June
27th June
10th July
20th July
31st July
16th August