-
Notifications
You must be signed in to change notification settings - Fork 888
Expand file tree
/
Copy pathpecl.xml
More file actions
638 lines (622 loc) · 18.5 KB
/
Copy pathpecl.xml
File metadata and controls
638 lines (622 loc) · 18.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="install.pecl" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Installation of PECL extensions</title>
&pecl.moving.to.pie;
<sect1 xml:id="install.pecl.intro">
<title>Introduction to PECL Installations</title>
&pecl.moving.to.pie;
<simpara>
&link.pecl; is a repository of PHP extensions that are made available via the
<link xlink:href="&url.php.pear;">PEAR</link>
packaging system.
This section of the manual is intended to demonstrate how to obtain and
install PECL extensions.
</simpara>
<simpara>
These instructions assume <literal>/path/to/php/src/dir/</literal> is the
path to the PHP source distribution and that <literal>extname</literal> is
the name of the PECL extension. Adjust accordingly.
These instructions also assume a familiarity with the
<link xlink:href="&url.php.pear.cli;">pear command</link>.
The information in the PEAR manual for the
<command>pear</command>
command also applies to the
<command>pecl</command>
command.
</simpara>
<simpara>
A shared extension must be built, installed, and loaded to be useful.
The methods described below provide various instructions on how to build and
install the extensions, but they do not automatically load them.
Extensions can be loaded by adding an
<link linkend="ini.extension">extension</link>
directive to the &php.ini; file or through the use of the
<function>dl</function>
function.
</simpara>
<simpara>
When building PHP modules, it's important to have known-good versions of the
required tools (autoconf, automake, libtool, etc.).
See the
<link xlink:href="&url.php.anongit;">Anonymous Git Instructions</link>
for details on the required tools and required versions.
</simpara>
</sect1>
<sect1 xml:id="install.pecl.downloads">
<title>Downloading PECL extensions</title>
&pecl.moving.to.pie;
<simpara>
There are several options for downloading PECL extensions, such as:
</simpara>
<itemizedlist>
<listitem>
<simpara>
The <command>pecl install extname</command> command downloads the
extensions code automatically, so in this case, there is no need for a
separate download.
</simpara>
</listitem>
<listitem>
<simpara>
<link xlink:href="&url.pecl;">&url.pecl;</link>
</simpara>
<simpara>
The PECL website contains information about the different extensions that
are offered by the PHP Development Team.
The information available here includes: changelog, release notes,
requirements, and other similar details.
</simpara>
</listitem>
<listitem>
<simpara>
<command>pecl download extname</command>
</simpara>
<simpara>
PECL extensions that have releases listed on the PECL website are available
for download and installation using the
<link xlink:href="&url.php.pear.cli;">pecl command</link>.
Specific revisions may also be specified.
</simpara>
</listitem>
<listitem>
<simpara>
<acronym>git</acronym>
</simpara>
<simpara>
Many PECL extensions reside on GitHub.
<!-- TODO Expand -->
</simpara>
</listitem>
<listitem>
<simpara>
<acronym>SVN</acronym>
</simpara>
<simpara>
Some PECL extensions also reside in <acronym>SVN</acronym>.
A web-based view may be seen at
<link xlink:href="&url.php.svn;pecl/">&url.php.svn;pecl/</link>.
To download straight from <acronym>SVN</acronym>,
the following sequence of commands may be used:
</simpara>
<screen>
<![CDATA[
$ svn checkout https://svn.php.net/repository/pecl/extname/trunk extname
]]>
</screen>
</listitem>
<listitem>
<simpara>
Windows downloads
</simpara>
<simpara>
The PHP project compiles and offers Windows DLLs for most PECL extensions
on the package page.
</simpara>
</listitem>
</itemizedlist>
</sect1>
<sect1 xml:id="install.pecl.windows">
<title>Installing a PHP extension on Windows</title>
&pecl.moving.to.pie;
<para>
There are two ways to load a PHP extension on Windows: either compile it into
PHP, or load the DLL.
Loading a pre-compiled extension is the easiest and preferred way.
</para>
<para>
To load an extension, it has to be available as a
<filename>.dll</filename>
file on the system.
All the extensions are automatically and periodically compiled by the PHP
Group (see next section for the download).
</para>
<para>
To compile an extension into PHP, please refer to the
<link linkend="install.windows.building">building from source</link>
documentation.
</para>
<para>
To compile a standalone extension (aka a DLL file), please refer to the
<link linkend="install.windows.building">building from source</link>
documentation.
If the DLL file is available neither with the PHP distribution nor in PECL,
it may be necessary to compile it before the extension can be used.
</para>
<sect2 xml:id="install.pecl.windows.find">
<title>Where to find an extension?</title>
<para>
PHP extensions are usually called <filename>php_*.dll</filename> (where the
star represents the name of the extension), and they are located under the
<filename>PHP\ext</filename>
folder.
</para>
<para>
PHP ships with the extensions most useful to the majority of developers.
They are called <emphasis>bundled</emphasis> extensions.
</para>
<para>
However, if the bundled extensions do not provide the needed functionality,
one extension that does may still be found in &link.pecl;.
The PHP Extension Community Library (PECL) is a repository for PHP
Extensions, providing a directory of all known extensions and hosting
facilities for downloading and developing PHP extensions.
</para>
<para>
If an extension has been developed for particular uses, it may be hosted on
PECL so that others with the same needs can benefit from it.
A nice side effect is that it's a good chance to receive feedback,
(hopefully) thanks, bug reports and even fixes/patches.
Before submitting an extension for hosting on PECL, please read
<link xlink:href="&url.pecl.submit;">PECL submit</link>.
</para>
</sect2>
<sect2 xml:id="install.pecl.windows.which">
<title>Which extension to download?</title>
<para>
<emphasis>
Many times, there will be several versions of each DLL available:
</emphasis>
<itemizedlist>
<listitem>
<simpara>
Different version numbers (at least the first two numbers should match)
</simpara>
</listitem>
<listitem>
<simpara>
Different thread safety settings
</simpara>
</listitem>
<listitem>
<simpara>
Different processor architecture (x86, x64, ...)
</simpara>
</listitem>
<listitem>
<simpara>
Different debugging settings
</simpara>
</listitem>
<listitem>
<simpara>
<literal>etc.</literal>
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
Keep in mind that the extension settings should match all the settings of
the PHP executable being used.
The following PHP script will tell <emphasis>all</emphasis> about the PHP
settings:
</para>
<para>
<example>
<title>
<function>phpinfo</function>
call
</title>
<programlisting role="php">
<![CDATA[
<?php
phpinfo();
?>
]]>
</programlisting>
</example>
</para>
<para>
Or from the command line, run:
<screen>
<![CDATA[
drive:\path\to\php\executable\php.exe -i
]]>
</screen>
</para>
</sect2>
<sect2 xml:id="install.pecl.windows.loading">
<title>Loading an extension</title>
<para>
The most common way to load a PHP extension is to include it in
the &php.ini; configuration file.
Please note that many extensions are already present in the &php.ini; and
that the semicolon only needs to be removed to activate them.
</para>
<para>
Note that, as of PHP 7.2.0, the extension name may be used
instead of the extension's file name.
As this is OS-independent and easier, especially for newcomers, it becomes
the recommended way of specifying extensions to load.
File names remain supported for compatibility with prior versions.
</para>
<screen>
<![CDATA[
;extension=php_extname.dll
]]>
</screen>
<screen>
<![CDATA[
extension=php_extname.dll
]]>
</screen>
<screen>
<![CDATA[
; As of PHP 7.2.0, prefer:
extension=extname
zend_extension=another_extension
]]>
</screen>
<para>
However, some web servers are confusing because they do not use
the &php.ini; located alongside the PHP executable.
To find out where the actual &php.ini; resides, look for its path
in <function>phpinfo</function>:
</para>
<screen>
<![CDATA[
Configuration File (php.ini) Path C:\WINDOWS
]]>
</screen>
<screen>
<![CDATA[
Loaded Configuration File C:\Program Files\PHP\8.2\php.ini
]]>
</screen>
<para>
After activating an extension, save &php.ini;, restart the web server, and
check <function>phpinfo</function> again.
The new extension should now have its own section.
</para>
</sect2>
<sect2 xml:id="install.pecl.windows.problemsolving">
<title>Resolving problems</title>
<para>
If the extension does not appear in <function>phpinfo</function>,
the logs should be checked to learn where the problem comes from.
</para>
<para>
If PHP is being used from the command line (CLI), the extension loading
error can be read directly on the screen.
</para>
<para>
If PHP is being used with a web server, the location and format of the logs
vary depending on the software.
Please read the web server documentation to locate the logs, as it has
nothing to do with PHP itself.
</para>
<para>
Common problems are the location of the DLL and the DLLs it depends on, the
value of the "<link linkend="ini.extension-dir">extension_dir</link>"
setting inside &php.ini; and compile-time setting mismatches.
</para>
<para>
If the problem lies in a compile-time setting mismatch, probably the DLL
downloaded is not the right one.
Try downloading the extension again with the proper settings.
Again, <function>phpinfo</function> can be of great help.
</para>
</sect2>
</sect1>
<sect1 xml:id="install.pecl.pear">
<title>Compiling shared PECL extensions with the pecl command</title>
&pecl.moving.to.pie;
<simpara>
PECL makes it easy to create shared PHP extensions.
Using the
<link xlink:href="&url.php.pear.cli;">pecl command</link>,
do the following:
</simpara>
<screen>
<![CDATA[
$ pecl install extname
]]>
</screen>
<simpara>
This will download the source for <emphasis>extname</emphasis>,
compile, and install <filename>extname.so</filename> into the
<link linkend="ini.extension-dir">extension_dir</link>.
<filename>extname.so</filename>
may then be loaded via &php.ini;.
</simpara>
<simpara>
By default, the <command>pecl</command> command will not install packages
that are marked with the <literal>alpha</literal> or
<literal>beta</literal>
state.
If no <literal>stable</literal> packages are available,
a <literal>beta</literal> package may be installed using the following
command:
</simpara>
<screen>
<![CDATA[
$ pecl install extname-beta
]]>
</screen>
<para>
A specific version may also be installed using this variant:
</para>
<screen>
<![CDATA[
$ pecl install extname-0.1
]]>
</screen>
<note>
<para>
After enabling the extension in &php.ini;, restarting the web service is
required for the changes to be picked up.
</para>
</note>
</sect1>
<sect1 xml:id="install.pecl.phpize">
<title>Compiling shared PECL extensions with phpize</title>
&pecl.moving.to.pie;
<simpara>
Sometimes, using the <command>pecl</command> installer is not an option.
This could be because there is a firewall or because the extension being
installed is unavailable as a PECL-compatible package, such as unreleased
extensions from git.
If such an extension needs to be built, the lower-level build tools can be
used to perform the build manually.
</simpara>
<simpara>
The <command>phpize</command> command is used to prepare the build
environment for a PHP extension.
In the following sample, the sources for an extension are in a directory
named <filename>extname</filename>:
</simpara>
<para>
<screen>
<![CDATA[
$ cd extname
$ phpize
$ ./configure
$ make
# make install
]]>
</screen>
</para>
<simpara>
A successful install will have created <filename>extname.so</filename> and
put it into the PHP
<link linkend="ini.extension-dir">extensions directory</link>.
The &php.ini; will need to be adjusted, and an
<literal>extension=extname.so</literal>
line will need to be added before the extension can be used.
</simpara>
<simpara>
If the system is missing the <command>phpize</command> command, and
precompiled packages (like RPM's) are used, be sure to install also the
appropriate development version of the PHP package as they often include the
<command>phpize</command>
command along with the proper header files to build PHP and its extensions.
</simpara>
<simpara>
Execute <command>phpize --help</command> to display additional usage
information.
</simpara>
</sect1>
<sect1 xml:id="install.pecl.php-config">
<title>
<command>php-config</command>
</title>
&pecl.moving.to.pie;
<para>
<command>php-config</command>
is a simple shell script for obtaining information about the installed PHP
configuration.
</para>
<para>
When the extensions are being compiled, if multiple PHP versions are
installed, the installation for which to build can be specified by using the
<option role="configure">--with-php-config</option>
option during configuration, setting the path of the respective
<command>php-config</command>
script.
</para>
<para>
The list of command line options provided by the
<command>php-config</command>
script can be queried anytime by running
<command>php-config</command>
with the <option>-h</option> switch:
<screen>
<![CDATA[
Usage: /usr/local/bin/php-config [OPTION]
Options:
--prefix [...]
--includes [...]
--ldflags [...]
--libs [...]
--extension-dir [...]
--include-dir [...]
--php-binary [...]
--php-sapis [...]
--configure-options [...]
--version [...]
--vernum [...]
]]>
</screen>
</para>
<para>
<table>
<title>Command line options</title>
<tgroup cols="2">
<thead>
<row>
<entry>Option</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>--prefix</entry>
<entry>Directory prefix where PHP is installed, e.g. /usr/local</entry>
</row>
<row>
<entry>--includes</entry>
<entry>
List of <literal>-I</literal> options with all include files
</entry>
</row>
<row>
<entry>--ldflags</entry>
<entry>
<literal>LD</literal>
flags which PHP was compiled with
</entry>
</row>
<row>
<entry>--libs</entry>
<entry>Extra libraries which PHP was compiled with</entry>
</row>
<row>
<entry>--extension-dir</entry>
<entry>Directory where extensions are searched by default</entry>
</row>
<row>
<entry>--include-dir</entry>
<entry>
Directory prefix where header files are installed by default
</entry>
</row>
<row>
<entry>--php-binary</entry>
<entry>Full path to php CLI or CGI binary</entry>
</row>
<row>
<entry>--php-sapis</entry>
<entry>Show all SAPI modules available</entry>
</row>
<row>
<entry>--configure-options</entry>
<entry>
Configure options to recreate configuration of current PHP installation
</entry>
</row>
<row>
<entry>--version</entry>
<entry>PHP version</entry>
</row>
<row>
<entry>--vernum</entry>
<entry>PHP version as integer</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</sect1>
<sect1 xml:id="install.pecl.static">
<title>Compiling PECL extensions statically into PHP</title>
&pecl.moving.to.pie;
<simpara>
It may be necessary to build a PECL extension statically into the PHP binary.
To do this, the extension source will need to be placed under the
<filename>/path/to/php/src/dir/ext/</filename>
directory, and the PHP build system will be required to regenerate its
configure script.
</simpara>
<para>
<screen>
<![CDATA[
$ cd /path/to/php/src/dir/ext
$ pecl download extname
$ gzip -d < extname.tgz | tar -xvf -
$ mv extname-x.x.x extname
]]>
</screen>
</para>
<simpara>
This will result in the following directory:
</simpara>
<screen>
<![CDATA[
/path/to/php/src/dir/ext/extname
]]>
</screen>
<simpara>
From here, PHP needs to be forced to rebuild the configure script, and then
it can be built as normal:
</simpara>
<screen>
<![CDATA[
$ cd /path/to/php/src/dir
$ rm configure
$ ./buildconf --force
$ ./configure --help
$ ./configure --with-extname --enable-someotherext --with-foobar
$ make
$ make install
]]>
</screen>
<note>
<simpara>
To run the <command>buildconf</command> script, the
<command>autoconf</command>
<literal>2.68</literal>
and
<command>automake</command>
<literal>1.4+</literal>
will be needed.
Newer versions of <command>autoconf</command> may work but are not
supported.
</simpara>
</note>
<simpara>
Whether
<option role="configure">--enable-extname</option>
or
<option role="configure">--with-extname</option>
is used depends on the extension.
Typically, an extension that does not require external libraries uses
<option role="configure">--enable</option>.
To be sure, run the following after <command>buildconf</command>:
</simpara>
<screen>
<![CDATA[
$ ./configure --help | grep extname
]]>
</screen>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->