1
- HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
1
+ # HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
2
2
3
3
A self-contained extension can be distributed independently of
4
4
the PHP source. To create such an extension, two things are
@@ -10,7 +10,7 @@ HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
10
10
We will describe now how to create these and how to put things
11
11
together.
12
12
13
- PREPARING YOUR SYSTEM
13
+ ## PREPARING YOUR SYSTEM
14
14
15
15
While the result will run on any system, a developer's setup needs these
16
16
tools:
@@ -23,7 +23,7 @@ PREPARING YOUR SYSTEM
23
23
24
24
ftp://ftp.gnu.org/pub/gnu/
25
25
26
- CONVERTING AN EXISTING EXTENSION
26
+ ## CONVERTING AN EXISTING EXTENSION
27
27
28
28
Just to show you how easy it is to create a self-contained
29
29
extension, we will convert an embedded extension into a
@@ -56,7 +56,7 @@ CONVERTING AN EXISTING EXTENSION
56
56
library or the MySQL installation in MYSQL-DIR.
57
57
58
58
59
- DEFINING THE NEW EXTENSION
59
+ ## DEFINING THE NEW EXTENSION
60
60
61
61
Our demo extension is called "foobar".
62
62
@@ -72,13 +72,13 @@ DEFINING THE NEW EXTENSION
72
72
LTLIBRARY_SOURCES specifies the names of the sources files. You can
73
73
name an arbitrary number of source files here.
74
74
75
- CREATING THE M4 CONFIGURATION FILE
75
+ ## CREATING THE M4 CONFIGURATION FILE
76
76
77
77
The m4 configuration can perform additional checks. For a
78
78
self-contained extension, you do not need more than a few
79
79
macro calls.
80
80
81
- ------------------------------------------------------------------------------
81
+ ```
82
82
PHP_ARG_ENABLE([foobar],
83
83
[whether to enable foobar],
84
84
[AS_HELP_STRING([--enable-foobar],
@@ -87,7 +87,7 @@ PHP_ARG_ENABLE([foobar],
87
87
if test "$PHP_FOOBAR" != "no"; then
88
88
PHP_NEW_EXTENSION(foobar, foo.c bar.c, $ext_shared)
89
89
fi
90
- ------------------------------------------------------------------------------
90
+ ```
91
91
92
92
PHP_ARG_ENABLE will automatically set the correct variables, so
93
93
that the extension will be enabled by PHP_NEW_EXTENSION in shared mode.
100
100
plan to distribute your module with PHP, these facilities allow you
101
101
to integrate your module easily into the main PHP module framework.
102
102
103
- CREATING SOURCE FILES
103
+ ## CREATING SOURCE FILES
104
104
105
105
ext_skel can be of great help when creating the common code for all modules
106
106
in PHP for you and also writing basic function definitions and C code for
@@ -111,7 +111,7 @@ CREATING SOURCE FILES
111
111
modules, use a simple module as a starting point and add your own code.
112
112
113
113
114
- CREATING THE SELF-CONTAINED EXTENSION
114
+ ## CREATING THE SELF-CONTAINED EXTENSION
115
115
116
116
Put config.m4 and the source files into one directory. Then, run phpize
117
117
(this is installed during make install by PHP 4.0).
@@ -125,15 +125,15 @@ CREATING THE SELF-CONTAINED EXTENSION
125
125
126
126
And that's it. You now have a self-contained extension.
127
127
128
- INSTALLING A SELF-CONTAINED EXTENSION
128
+ ## INSTALLING A SELF-CONTAINED EXTENSION
129
129
130
130
An extension can be installed by running:
131
131
132
132
$ ./configure \
133
133
[--with-php-config=/path/to/php-config]
134
134
$ make install
135
135
136
- ADDING SHARED MODULE SUPPORT TO A MODULE
136
+ ## ADDING SHARED MODULE SUPPORT TO A MODULE
137
137
138
138
In order to be useful, a self-contained extension must be loadable
139
139
as a shared module. I will explain now how you can add shared module
@@ -148,11 +148,13 @@ ADDING SHARED MODULE SUPPORT TO A MODULE
148
148
149
149
3 . Add the following lines to your C source file:
150
150
151
+ ```
151
152
#ifdef COMPILE_DL_FOO
152
153
ZEND_GET_MODULE(foo)
153
154
#endif
155
+ ```
154
156
155
- PECL SITE CONFORMITY
157
+ ## PECL SITE CONFORMITY
156
158
157
159
If you plan to release an extension to the PECL website, there are several
158
160
points to be regarded.
0 commit comments