-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathconfigure.xml
316 lines (282 loc) · 10.5 KB
/
configure.xml
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
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<section xml:id="mongodb.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<section xml:id="mongodb.installation.pecl">
<title>Installing the MongoDB PHP Extension with PECL</title>
<para>
&pecl.info;
<link xlink:href="&url.pecl.package;mongodb">&url.pecl.package;mongodb</link>
</para>
<para>
Linux, Unix, and macOS users may run the following command to install the
extension:
<programlisting role="shell">
<![CDATA[
$ sudo pecl install mongodb
]]>
</programlisting>
</para>
<para>
On systems with multiple version of PHP installed (e.g. macOS default,
Homebrew, <link xlink:href="&url.xampp;">XAMPP</link>), each version of PHP
will have its own <link linkend="install.pecl">pecl</link>
command and &php.ini; file(s). Additionally, each PHP environments (e.g.
CLI, web) may use separate &php.ini; files.
</para>
<para>
As of extension version 1.17.0, PECL will prompt for various
<literal>configure</literal> options. To install the extension with default
options in a non-interactive script, empty string input may be piped to
<literal>pecl install</literal> using the <literal>yes</literal> command:
<programlisting role="shell">
<![CDATA[
$ yes '' | sudo pecl install mongodb
]]>
</programlisting>
</para>
<para>
A complete list of supported <literal>configure</literal> options can be
found in the <literal>package.xml</literal> file included in the PECL
package. To install the extension with specific <literal>configure</literal>
options in a non-interactive script, the
<literal>--configureoptions</literal> option for
<literal>pecl install</literal> may be used:
<programlisting role="shell">
<![CDATA[
$ sudo pecl install --configureoptions='with-mongodb-system-libs="yes" enable-mongodb-developer-flags="no"' mongodb
]]>
</programlisting>
</para>
<para>
By default, installing the extension via PECL will use bundled versions of
<link xlink:href="&url.mongodb.libbson;">libbson</link>,
<link xlink:href="&url.mongodb.libmongoc;">libmongoc</link>, and
<link xlink:href="&url.mongodb.libmongocrypt;">libmongocrypt</link> and attempt to
automatically configure them.
</para>
<note>
<simpara>
If the build process fails to find an SSL library, check that the
development packages (e.g. <literal>libssl-dev</literal>) and
<link xlink:href="&url.mongodb.wiki.pkg-config;">pkg-config</link> are both
installed. If that does not resolve the problem, consider using the
<link linkend="mongodb.installation.manual">manual installation</link>
process.
</simpara>
</note>
<para>
Finally, add the following line to the &php.ini; file for each environment
that will need to use the extension:
<programlisting role="ini">
<![CDATA[
extension=mongodb.so
]]>
</programlisting>
</para>
</section>
<section xml:id="mongodb.installation.homebrew">
<title>Installing the MongoDB PHP Extension on macOS with Homebrew</title>
<para>
<link xlink:href="&url.brew.1.5.0;">Homebrew 1.5.0</link>
deprecated the <link xlink:href="&url.mac.homebrew;">Homebrew/php tap</link>
and removed formulae for individual PHP extensions. Going forward, macOS
users are advised to install the
<link xlink:href="&url.brew.php;">php</link> formula
and follow the standard
<link linkend="mongodb.installation.pecl">PECL installation instructions</link>
using the <link linkend="install.pecl">pecl</link> command provided by the
Homebrew PHP installation.
</para>
<para>
Alternatively, the
<link xlink:href="https://github.com/shivammathur/homebrew-extensions">shivammathur/extensions tap</link>
provides formulae for individual PHP extensions. For example, to install the
extension for PHP 8.4, run:
<programlisting role="shell">
<![CDATA[
$ brew install shivammathur/extensions/[email protected]
]]>
</programlisting>
Please note that only the latest extension version is available in brew.
</para>
<note>
<title>Install required dependencies</title>
<para>
To ensure that SSL support can be configured correctly, make sure that the
<literal>openssl</literal> and <literal>pkgconf</literal> formulae are
installed. If either of these packages are missing, the extension will be
compiled with Secure Transport, which can lead to compatibility issues.
</para>
</note>
</section>
<section xml:id="mongodb.installation.windows">
<title>Installing the MongoDB PHP Extension on Windows</title>
<para>
Precompiled binaries are attached to the project's
<link xlink:href="&url.mongodb.github.new;/releases/">Github releases</link>.
Archives are published for various combinations of PHP version, thread safety
(TS or NTS), and architecture (x86 or x64). Determining the correct archive
for the PHP environment and extract the <filename>php_mongodb.dll</filename>
file to the extension directory ("ext" by default).
</para>
<para>
Add the following line to the &php.ini; file for each environment that will
need to use the extension:
<programlisting role="ini">
<![CDATA[
extension=php_mongodb.dll
]]>
</programlisting>
</para>
<para>
Failure to select the correct binary will result in an error when attempting
to load the extension DLL at runtime:
<programlisting role="txt">
<![CDATA[
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb'
]]>
</programlisting>
</para>
<para>
Ensure that the downloaded DLL corresponds to the following PHP runtime
properties:
<simplelist>
<member>PHP version (<constant>PHP_VERSION</constant>)</member>
<member>Thread safety (<constant>PHP_ZTS</constant>)</member>
<member>Architecture (<constant>PHP_INT_SIZE</constant>)</member>
</simplelist>
</para>
<para>
In addition to the aforementioned constants, these properties can also be
inferred from <function>phpinfo</function>. If a system has multiple PHP
runtimes installed, double-check that the <function>phpinfo</function> output
is for the correct environment.
</para>
<note>
<title>Additional DLL dependencies for Windows Users</title>
<para>
&ext.windows.path.dll;
<filename>libsasl.dll</filename>
</para>
</note>
</section>
<section xml:id="mongodb.installation.manual">
<title>Building the MongoDB PHP Driver from source</title>
<para>
For developers and users interested in the latest bugfixes, the extension
may be compiled from the latest source code on
<link xlink:href="&url.mongodb.github.new;">Github</link>. Run the following
commands to clone and build the project:
<programlisting role="shell">
<![CDATA[
$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule update --init
$ phpize
$ ./configure
$ make all
$ sudo make install
]]>
</programlisting>
</para>
<para>
On systems with multiple version of PHP installed (e.g. macOS default,
Homebrew, <link xlink:href="&url.xampp;">XAMPP</link>), each version of PHP
will have its own <link linkend="install.pecl.phpize">phpize</link>
command and &php.ini; file(s). Additionally, each PHP environments (e.g.
CLI, web) may use separate &php.ini; files.
</para>
<para>
By default, the extension will use bundled versions of
<link xlink:href="&url.mongodb.libbson;">libbson</link>,
<link xlink:href="&url.mongodb.libmongoc;">libmongoc</link>, and
<link xlink:href="&url.mongodb.libmongocrypt;">libmongocrypt</link> and
attempt to configure them automatically. If these libraries are already
installed as system libraries, the extension can utilize them by
specifying <literal>--with-mongodb-system-libs=yes</literal> as an option to
<literal>configure</literal>.
</para>
<para>
For a complete list of <literal>configure</literal> options, run
<command>configure --help</command>.
</para>
<para>
When using bundled versions of libmongoc and libmongocrypt, the extension
will also attempt to select an SSL library according to the
<literal>--with-mongodb-ssl</literal> <literal>configure</literal> option.
As of extension version 1.17.0, OpenSSL is always preferred by default.
Previously, Secure Transport was the default on macOS and OpenSSL was the
default on all other platforms.
</para>
<note>
<para>
If the build process fails to find an SSL library, check that the
development packages (e.g. <literal>libssl-dev</literal>) and
<link xlink:href="&url.mongodb.wiki.pkg-config;">pkg-config</link> are both
installed.
</para>
<para>
When using Homebrew on macOS, it is common for a system to have multiple
versions of OpenSSL installed. To ensure that the desired version of OpenSSL
is selected, the <literal>PKG_CONFIG_PATH</literal> environment variable may
be used to control the search path for <literal>pkg-config</literal>.
</para>
</note>
<para>
The final build step, <command>make install</command>, will report where
<filename>mongodb.so</filename> has been installed, similar to:
<programlisting role="txt">
<![CDATA[
Installing shared extensions: /usr/lib/php/extensions/debug-non-zts-20220829/
]]>
</programlisting>
</para>
<para>
Ensure that the <link linkend="ini.extension-dir">extension_dir</link> option
in &php.ini; points to the directory where <filename>mongodb.so</filename>
was installed. The option may be queried by running:
<programlisting role="shell">
<![CDATA[
$ php -i | grep extension_dir
extension_dir => /usr/lib/php/extensions/debug-non-zts-20220829 =>
/usr/lib/php/extensions/debug-non-zts-20220829
]]>
</programlisting>
</para>
<para>
If the directories differ, either change
<link linkend="ini.extension-dir">extension_dir</link> in &php.ini; or
manually move <filename>mongodb.so</filename> to the correct directory.
</para>
<para>
Finally, add the following line to the &php.ini; file for each environment
that will need to use the extension:
<programlisting role="ini">
<![CDATA[
extension=mongodb.so
]]>
</programlisting>
</para>
</section>
</section>
<!-- 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
-->