PHP extension
This page is about the development of PHP extension in C++.
The official documentation about extensions on the official PHP web site is only about PHP 5, not PHP 7. The examples may compile properly under PHP 7, but they will not work properly.
Installation
Compilation
In the C/C++ source files you may found on the web, if there is a compilation error on
function_entry
, replace it with zend_function_entry
.
Macros
Windows
Macros definitions which seems to be needed for compilation under Windows :
ZEND_WIN32_FORCE_INLINE
,ZEND_WIN32=1
,PHP_WIN32=1
,__STDC_LIMIT_MACROS
,ZEND_DEBUG=0
,ZTS
.
The last one is only needed to compile in TS mode, not for the NTS mode.
Linking
Windows
You have to link against <php>/Release_TS/php5ts.lib
(obviously for the thread-safe version).
Activation
You have to :
- create a
.ini
file in/etc/php5/mods-available
which containsextension=<extension-name>.<libext>
,<libext>
being the dynamic library extension for the concerned OS, - launch as root
php5enmod <extension_name>
.
In order for the extension yo be recognized, verify that :
- the extension correspondent library
<extension_name>.<libext>
is present in the extension directory, - there is a
.ini
file in the/etc/php5/mods-available
directory which contains the lineextension=<extension-name>.<libext>
, - there is a link in the
conf.d
directory pointing to the above file.
Misc
- For the directory of the extensions :
php-config | grep extension
, - for the
.ini
filephp --ini
.