-HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
+# HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
A self-contained extension can be distributed independently of
the PHP source. To create such an extension, two things are
We will describe now how to create these and how to put things
together.
-PREPARING YOUR SYSTEM
+## PREPARING YOUR SYSTEM
While the result will run on any system, a developer's setup needs these
tools:
ftp://ftp.gnu.org/pub/gnu/
-CONVERTING AN EXISTING EXTENSION
+## CONVERTING AN EXISTING EXTENSION
Just to show you how easy it is to create a self-contained
extension, we will convert an embedded extension into a
library or the MySQL installation in MYSQL-DIR.
-DEFINING THE NEW EXTENSION
+## DEFINING THE NEW EXTENSION
Our demo extension is called "foobar".
LTLIBRARY_SOURCES specifies the names of the sources files. You can
name an arbitrary number of source files here.
-CREATING THE M4 CONFIGURATION FILE
+## CREATING THE M4 CONFIGURATION FILE
The m4 configuration can perform additional checks. For a
self-contained extension, you do not need more than a few
macro calls.
-------------------------------------------------------------------------------
+```
PHP_ARG_ENABLE([foobar],
[whether to enable foobar],
[AS_HELP_STRING([--enable-foobar],
if test "$PHP_FOOBAR" != "no"; then
PHP_NEW_EXTENSION(foobar, foo.c bar.c, $ext_shared)
fi
-------------------------------------------------------------------------------
+```
PHP_ARG_ENABLE will automatically set the correct variables, so
that the extension will be enabled by PHP_NEW_EXTENSION in shared mode.
plan to distribute your module with PHP, these facilities allow you
to integrate your module easily into the main PHP module framework.
-CREATING SOURCE FILES
+## CREATING SOURCE FILES
ext_skel can be of great help when creating the common code for all modules
in PHP for you and also writing basic function definitions and C code for
modules, use a simple module as a starting point and add your own code.
-CREATING THE SELF-CONTAINED EXTENSION
+## CREATING THE SELF-CONTAINED EXTENSION
Put config.m4 and the source files into one directory. Then, run phpize
(this is installed during make install by PHP 4.0).
And that's it. You now have a self-contained extension.
-INSTALLING A SELF-CONTAINED EXTENSION
+## INSTALLING A SELF-CONTAINED EXTENSION
An extension can be installed by running:
[--with-php-config=/path/to/php-config]
$ make install
-ADDING SHARED MODULE SUPPORT TO A MODULE
+## ADDING SHARED MODULE SUPPORT TO A MODULE
In order to be useful, a self-contained extension must be loadable
as a shared module. I will explain now how you can add shared module
3. Add the following lines to your C source file:
+```
#ifdef COMPILE_DL_FOO
ZEND_GET_MODULE(foo)
#endif
+```
-PECL SITE CONFORMITY
+## PECL SITE CONFORMITY
If you plan to release an extension to the PECL website, there are several
points to be regarded.
-PHP Build System V5 Overview
+# PHP Build System V5 Overview
- supports Makefile.ins during transition phase
- not-really-portable Makefile includes have been eliminated
- upgraded shtool to 1.5.4
- removed $(moduledir) (use EXTENSION_DIR)
-The Reason For a New System
+## The Reason For a New System
It became more and more apparent that there is a severe need
for addressing the portability concerns and improving the chance
that your build is correct (how often have you been told to
"make clean"? When this is done, you won't need to anymore).
-
-If You Build PHP on a Unix System
-
+## If You Build PHP on a Unix System
You, as a user of PHP, will notice no changes. Of course, the build
system will be faster, look better and work smarter.
+## If You Are Developing PHP
-
-If You Are Developing PHP
-
-
-
-
-Extension developers:
+### Extension developers:
Makefile.ins are abandoned. The files which are to be compiled
are specified in the config.m4 now using the following macro:
absolute paths or relative ones to the top build-directory.
Correct prefixing ensures that.
-
-SAPI developers:
+### SAPI developers:
Instead of using PHP_SAPI=foo/PHP_BUILD_XYZ, you will need to type
PHP_SELECT_SAPI(apache, shared, sapi_apache.c mod_php7.c php_apache.c)
-
-
-General info
+## General info
The foundation for the new system is the flexible handling of
sources and their contexts. With the help of macros you