QA-495: Document context options for setting SSL.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@333134 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Derick Rethans 2014-03-27 16:02:26 +00:00
parent f1759a0d8c
commit fb7390ad04

View file

@ -13,6 +13,7 @@
<modifier>public</modifier> <methodname>MongoClient::__construct</methodname>
<methodparam choice="opt"><type>string</type><parameter>server</parameter><initializer>"mongodb://localhost:27017"</initializer></methodparam>
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>array("connect" => &true;)</initializer></methodparam>
<methodparam choice="opt"><type>array</type><parameter>driver_options</parameter></methodparam>
</constructorsynopsis>
<para>
If no parameters are passed, this connects to "localhost:27017" (or whatever
@ -325,6 +326,32 @@ mongodb://[username:password@]host1[:port1][,host2[:port2:],...]/db
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>driver_options</parameter>
</term>
<listitem>
<para>
An array of options for the MongoDB driver. Options include setting
connection context options for SSL or logging callbacks.
<itemizedlist>
<listitem>
<para>
<literal>"context"</literal>
</para>
<para>
A way to pass in context options. Context options allow you to
configure SSL certificates and are described at <link
linkend="context.ssl">SSL context options</link>. There is an <link
linkend="mongoclient.construct.context.ssl">example</link> further
down that shows you how to use this.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
@ -428,7 +455,7 @@ $m = new MongoClient("mongodb:///tmp/mongodb-27017.sock,localhost:27017");
A user must exist in the admin database before attempting to use
authentication. You can create one with the Mongo shell by running:
</para>
<programlisting>
<programlisting role="shell">
<![CDATA[
> use admin
switched to db admin
@ -485,7 +512,7 @@ $m = new MongoClient($uri, array('replicaSet' => 'rs'));
Here we set the journal option to true and readPreference to secondary
preferred as default for all write operations:
</para>
<programlisting>
<programlisting role="php">
<![CDATA[
<?php
$m = new MongoClient("mongodb://localhost/?journal=true&readPreference=secondary");
@ -495,7 +522,7 @@ $m = new MongoClient("mongodb://localhost/?journal=true&readPreference=secondary
<para>
And now we do the same, but as an options array:
</para>
<programlisting>
<programlisting role="php">
<![CDATA[
<?php
$options = array(
@ -520,6 +547,33 @@ $uri .= '?readPreference=nearest';
$uri .= '&readPreferenceTags=dc:east';
$m = new MongoClient($uri, array('replicaSet' => 'rs'));
?>
]]>
</programlisting>
<para>
See the <link linkend="mongo.readpreferences">read preferences</link>
section of this manual for further information.
</para>
</example>
<example xml:id="mongoclient.construct.context.ssl">
<title><function>MongoClient::__construct</function> connecting with SSL
certifications example</title>
<programlisting role="php">
<![CDATA[
<?php
$ctx = stream_context_create( array(
'ssl' => array(
'local_cert' => '/vagrant/certs/client.pem',
'cafile' => '/vagrant/certs/ca.pem',
)
) );
$m = new MongoClient(
"mongodb://mongod/?ssl=true",
array(),
array('context' => $ctx)
);
?>
]]>
</programlisting>
<para>