Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 10137

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create new MongoDB Manager</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongodb-driver-manager.html">MongoDB\Driver\Manager</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb-driver-manager.executebulkwrite.html">MongoDB\Driver\Manager::executeBulkWrite</a></div>
 <div class="up"><a href="class.mongodb-driver-manager.html">MongoDB\Driver\Manager</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongodb-driver-manager.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Manager::__construct</h1>
  <p class="verinfo">(mongodb &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Manager::__construct</span> &mdash; <span class="dc-title">Create new MongoDB Manager</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-manager.construct-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Manager::__construct</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$uri</code><span class="initializer"> = &quot;mongodb://127.0.0.1/&quot;</span></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$uriOptions</code><span class="initializer"> = array()</span></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$driverOptions</code><span class="initializer"> = array()</span></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   Constructs a new <a href="class.mongodb-driver-manager.html" class="classname">MongoDB\Driver\Manager</a> object with the specified options.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Per the <a href="https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#single-threaded-client-construction" class="link external">&raquo;&nbsp;Server Discovery and Monitoring Specification</a>,
    this constructor performs no I/O. Connections will be initialized on demand,
    when the first operation is executed.
   </span>
  </p></blockquote>
  
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <span class="simpara">
     On Unix platforms, the MongoDB driver is sensitive to scripts that use the
     fork() system call without also calling exec(). Users are advised not to
     re-use <a href="class.mongodb-driver-manager.html" class="classname">MongoDB\Driver\Manager</a> instances in a forked
     child process.
    </span>
   </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-manager.construct-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
    <dt id="mongodb-driver-manager.construct-uri"><code class="parameter">uri</code></dt>

    <dd>

     <p class="para">
      A <a href="https://docs.mongodb.com/manual/reference/connection-string/" class="link external">&raquo;&nbsp;mongodb://</a> connection URI:
      <div class="example-contents">
<div class="txtcode"><pre class="txtcode">mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]</pre>
</div>
      </div>

     </p>
     <p class="para">
      For details on supported options, see
      <a href="https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options" class="link external">&raquo;&nbsp;Connection String Options</a>
      in the MongoDB manual.
      <a href="https://docs.mongodb.com/manual/reference/connection-string/#connection-pool-options" class="link external">&raquo;&nbsp;Connection pool options</a>
      are not supported, as the PHP driver does not implement connection pools.
     </p>
     <p class="para">
      The <code class="parameter">uri</code> is a URL, hence any special characters in
      its components need to be URL encoded according to
      <a href="http://www.faqs.org/rfcs/rfc3986" class="link external">&raquo;&nbsp;RFC 3986</a>. This is particularly
      relevant to the username and password, which can often include special
      characters such as <em>@</em>, <em>:</em>, or
      <em>%</em>. When connecting via a Unix domain socket, the socket
      path may contain special characters such as slashes and must be encoded.
      The <span class="function"><a href="function.rawurlencode.html" class="function">rawurlencode()</a></span> function may be used to encode
      constituent parts of the URI.
     </p>
    </dd>

   
   
    <dt id="mongodb-driver-manager.construct-urioptions"><code class="parameter">uriOptions</code></dt>

    <dd>

     <p class="para">
      Additional
      <a href="https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options" class="link external">&raquo;&nbsp;connection string options</a>,
      which will overwrite any options with the same name in the
      <code class="parameter">uri</code> parameter.
     </p>
     <p class="para">
      <table class="doctable table">
       <caption><strong>uriOptions</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>appname</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            MongoDB 3.4+ has the ability to annotate connections with metadata
            provided by the connecting client. This metadata is included in the
            server&#039;s logs upon establishing a connection and also recorded in
            slow query logs when database profiling is enabled.
           </p>
           <p class="para">
            This option may be used to specify an application name, which will
            be included in the metadata. The value cannot exceed 128 characters
            in length.
           </p>
          </td>
         </tr>

         <tr>
          <td>authMechanism</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            The authentication mechanism that MongoDB will use to authenticate
            the connection. For additional details and a list of supported
            values, see
            <a href="https://docs.mongodb.com/manual/reference/connection-string/#urioption.authMechanism" class="link external">&raquo;&nbsp;Authentication Options</a>
            in the MongoDB manual.
           </p>
          </td>
         </tr>

         <tr>
          <td>authMechanismProperties</td>
          <td><span class="type"><a href="language.types.array.html" class="type array">array</a></span></td>
          <td>
           <p class="para">
            Properties for the selected authentication mechanism. For additional
            details and a list of supported properties, see the
            <a href="https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst#auth-related-options" class="link external">&raquo;&nbsp;Driver Authentication Specification</a>.
           </p>
           <blockquote class="note"><p><strong class="note">Note</strong>: 
            <span class="simpara">
             When not specified in the URI string, this option is expressed as
             an array of key/value pairs. The keys and values in this array
             should be strings.
            </span>
           </p></blockquote>
          </td>
         </tr>

         <tr>
          <td>authSource</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            The database name associated with the user&#039;s credentials. Defaults
            to the database component of the connection URI.
           </p>
           <p class="para">
            For authentication mechanisms that delegate credential storage to
            other services (e.g. GSSAPI), this should be
            <em>&quot;$external&quot;</em>.
           </p>
          </td>
         </tr>

         <tr>
          <td>canonicalizeHostname</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            If <strong><code>TRUE</code></strong>, the driver will resolve the real hostname for the server
            IP address before authenticating via SASL. Some underlying GSSAPI
            layers already do this, but the functionality may be disabled in
            their config (e.g. <em>krb.conf</em>). Defaults to
            <strong><code>FALSE</code></strong>.
           </p>
           <p class="para">
            This option is a deprecated alias for the
            <em>&quot;CANONICALIZE_HOST_NAME&quot;</em> property of the
            <em>&quot;authMechanismProperties&quot;</em> URI option.
           </p>
          </td>
         </tr>

         <tr>
          <td>compressors</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            A prioritized, comma-delimited list of compressors that the client
            wants to use. Messages are only compressed if the client and server
            share any compressors in common, and the compressor used in each
            direction will depend on the individual configuration of the server
            or driver. See the
            <a href="https://github.com/mongodb/specifications/blob/master/source/compression/OP_COMPRESSED.rst#compressors" class="link external">&raquo;&nbsp;Driver Compression Specification</a>
            for more information.
           </p>
          </td>
         </tr>

         <tr id="mongodb-driver-manager.construct-urioptions.connecttimeoutms">
          <td>connectTimeoutMS</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            The time in milliseconds to attempt a connection before timing out.
            Defaults to 10,000 milliseconds.
           </p>
          </td>
         </tr>

         <tr>
          <td>gssapiServiceName</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Set the Kerberos service name when connecting to Kerberized MongoDB
            instances. This value must match the service name set on MongoDB
            instances (i.e.
            <a href="https://docs.mongodb.com/manual/reference/parameters/#param.saslServiceName" class="link external">&raquo;&nbsp;saslServiceName</a>
            server parameter). Defaults to <em>&quot;mongodb&quot;</em>.
           </p>
           <p class="para">
            This option is a deprecated alias for the
            <em>&quot;SERVICE_NAME&quot;</em> property of the
            <em>&quot;authMechanismProperties&quot;</em> URI option.
           </p>
          </td>
         </tr>

         <tr>
          <td>heartbeatFrequencyMS</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            Specifies the interval in milliseconds between the driver&#039;s checks
            of the MongoDB topology, counted from the end of the previous check 
            until the beginning of the next one. Defaults to 60,000
            milliseconds.
           </p>
           <p class="para">
            Per the
            <a href="https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#heartbeatfrequencyms" class="link external">&raquo;&nbsp;Server Discovery and Monitoring Specification</a>,
            this value cannot be less than 500 milliseconds.
           </p>
          </td>
         </tr>

         <tr>
          <td>journal</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            Corresponds to the default write concern&#039;s
            <code class="parameter">journal</code> parameter. If <strong><code>TRUE</code></strong>, writes will
            require acknowledgement from MongoDB that the operation has been
            written to the journal. For details, see
            <a href="class.mongodb-driver-writeconcern.html" class="classname">MongoDB\Driver\WriteConcern</a>.
           </p>
          </td>
         </tr>

         <tr>
          <td>localThresholdMS</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            The size in milliseconds of the latency window for selecting among
            multiple suitable MongoDB instances while resolving a read
            preference. Defaults to 15 milliseconds.
           </p>
          </td>
         </tr>

         <tr>
          <td>maxStalenessSeconds</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            Corresponds to the read preference&#039;s
            <em>&quot;maxStalenessSeconds&quot;</em>. Specifies, in seconds, how
            stale a secondary can be before the client stops using it for read
            operations. By default, there is no maximum staleness and clients
            will not consider a secondary’s lag when choosing where to direct a
            read operation. For details, see
            <a href="class.mongodb-driver-readpreference.html" class="classname">MongoDB\Driver\ReadPreference</a>.
           </p>
           <p class="para">
            If specified, the max staleness must be a signed 32-bit integer
            greater than or equal to
            <strong><code>MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS</code></strong>
            (i.e. 90 seconds).
           </p>
          </td>
         </tr>

         <tr>
          <td>password</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           The password for the user being authenticated. This option is useful
           if the password contains special characters, which would otherwise
           need to be URL encoded for the connection URI.
          </td>
         </tr>

         <tr>
          <td>readConcernLevel</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           Corresponds to the read concern&#039;s <code class="parameter">level</code>
           parameter. Specifies the level of read isolation. For details, see
           <a href="class.mongodb-driver-readconcern.html" class="classname">MongoDB\Driver\ReadConcern</a>.
          </td>
         </tr>

         <tr>
          <td>readPreference</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Corresponds to the read preferences&#039;s <code class="parameter">mode</code>
            parameter. Defaults to <em>&quot;primary&quot;</em>. For
            details, see <a href="class.mongodb-driver-readpreference.html" class="classname">MongoDB\Driver\ReadPreference</a>.
           </p>
          </td>
         </tr>

         <tr>
          <td>readPreferenceTags</td>
          <td><span class="type"><a href="language.types.array.html" class="type array">array</a></span></td>
          <td>
           <p class="para">
            Corresponds to the read preferences&#039;s <code class="parameter">tagSets</code>
            parameter. Tag sets allow you to target read operations to specific
            members of a replica set. For details, see
            <a href="class.mongodb-driver-readpreference.html" class="classname">MongoDB\Driver\ReadPreference</a>.
           </p>
           <blockquote class="note"><p><strong class="note">Note</strong>: 
            <span class="simpara">
             When not specified in the URI string, this option is expressed as
             an array consistent with the format expected by
             <span class="function"><a href="mongodb-driver-readpreference.construct.html" class="function">MongoDB\Driver\ReadPreference::__construct()</a></span>.
            </span>
           </p></blockquote>
          </td>
         </tr>

         <tr>
          <td>replicaSet</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Specifies the name of the replica set.
           </p>
          </td>
         </tr>

         <tr>
          <td>retryWrites</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            If <strong><code>TRUE</code></strong>, the driver will automatically retry certain write
            operations that fail due to transient network errors or replica set
            elections. Defaults to <strong><code>FALSE</code></strong>.
           </p>
           <p class="para">
            See
            <a href="https://docs.mongodb.com/manual/core/distributed-queries/#retryable-writes" class="link external">&raquo;&nbsp;Retryable Writes</a>
            in the MongoDB manual for more information.
           </p>
          </td>
         </tr>

         <tr>
          <td>safe</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            If <strong><code>TRUE</code></strong>, specifies <em>1</em> for the default write
            concern&#039;s <code class="parameter">w</code> parameter. If <strong><code>FALSE</code></strong>,
            <em>0</em> is specified. For details, see
            <a href="class.mongodb-driver-writeconcern.html" class="classname">MongoDB\Driver\WriteConcern</a>.
           </p>
           <p class="para">
            This option is deprecated and should not be used.
           </p>
          </td>
         </tr>

         <tr id="mongodb-driver-manager.construct-urioptions.serverselectiontimeoutms">
          <td>serverSelectionTimeoutMS</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            Specifies how long in milliseconds to block for server selection
            before throwing an exception. Defaults to 30,000 milliseconds.
           </p>
          </td>
         </tr>

         <tr>
          <td>serverSelectionTryOnce</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            When <strong><code>TRUE</code></strong>, instructs the driver to scan the MongoDB deployment
            exactly once after server selection fails and then either select a
            server or raise an error. When <strong><code>FALSE</code></strong>, the driver blocks and
            searches for a server up to the
            <em>&quot;serverSelectionTimeoutMS&quot;</em> value. Defaults to
            <strong><code>TRUE</code></strong>.
           </p>
          </td>
         </tr>

         <tr>
          <td>slaveOk</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            Specifies <em>&quot;secondaryPreferred&quot;</em> for the read
            preference mode if <strong><code>TRUE</code></strong>. For details, see
            <a href="class.mongodb-driver-readpreference.html" class="classname">MongoDB\Driver\ReadPreference</a>.
           </p>
           <p class="para">
            This option is deprecated and should not be used.
           </p>
          </td>
         </tr>

         <tr>
          <td>socketCheckIntervalMS</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            If a socket has not been used recently, the driver must check it via
            an <em>isMaster</em> command before using it for any
            operation. Defaults to 5,000 milliseconds.
           </p>
          </td>
         </tr>

         <tr>
          <td>socketTimeoutMS</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            The time in milliseconds to attempt a send or receive on a socket
            before timing out. Defaults to 300,000 milliseconds (i.e. five
            minutes).
           </p>
          </td>
         </tr>

         <tr>
          <td>ssl</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            Initiates the connection with TLS/SSL if <strong><code>TRUE</code></strong>. Defaults to
            <strong><code>FALSE</code></strong>.
           </p>
          </td>
         </tr>

         <tr>
          <td>username</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           The username for the user being authenticated. This option is useful
           if the username contains special characters, which would otherwise
           need to be URL encoded for the connection URI.
          </td>
         </tr>

         <tr>
          <td>w</td>
          <td><span class="type"><span class="type integer|string">integer|string</span></span></td>
          <td>
           <p class="para">
            Corresponds to the default write concern&#039;s
            <code class="parameter">w</code> parameter. For details, see
            <a href="class.mongodb-driver-writeconcern.html" class="classname">MongoDB\Driver\WriteConcern</a>.
           </p>
          </td>
         </tr>

         <tr>
          <td>wTimeoutMS</td>
          <td><span class="type"><span class="type integer|string">integer|string</span></span></td>
          <td>
           <p class="para">
            Corresponds to the default write concern&#039;s
            <code class="parameter">wtimeout</code> parameter. Specifies a time limit,
            in milliseconds, for the write concern. For details, see
            <a href="class.mongodb-driver-writeconcern.html" class="classname">MongoDB\Driver\WriteConcern</a>.
           </p>
           <p class="para">
            If specified, <em>wTimeoutMS</em> must be a signed 32-bit
            integer greater than or equal to zero.
           </p>
          </td>
         </tr>

         <tr>
          <td>zlibCompressionLevel</td>
          <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
          <td>
           <p class="para">
            Specifies the compression level to use for the zlib compressor. This
            option has no effect if <em>zlib</em> is not included in
            the <em>&quot;compressors&quot;</em> URI option. See the
            <a href="https://github.com/mongodb/specifications/blob/master/source/compression/OP_COMPRESSED.rst#zlibcompressionlevel" class="link external">&raquo;&nbsp;Driver Compression Specification</a>
            for more information.
           </p>
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>

   
   
    <dt id="mongodb-driver-manager.construct-driveroptions"><code class="parameter">driverOptions</code></dt>

    <dd>

     <p class="para">
      <table class="doctable table">
       <caption><strong>driverOptions</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>allow_invalid_hostname</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            Disables hostname validation if <strong><code>TRUE</code></strong>. Defaults to <strong><code>FALSE</code></strong>.
           </p>
           <p class="para">
            Allowing invalid hostnames may expose the driver to a
            <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack" class="link external">&raquo;&nbsp;man-in-the-middle attack</a>.
           </p>
          </td>
         </tr>

         <tr>
          <td>ca_dir</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Path to a correctly hashed certificate directory. The system
            certificate store will be used by default.
           </p>
           <p class="para">
            Falls back to the deprecated <em>&quot;capath&quot;</em> SSL context
            option if not specified.
           </p>
          </td>
         </tr>

         <tr>
          <td>ca_file</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Path to a certificate authority file. The system certificate store
            will be used by default.
           </p>
           <p class="para">
            Falls back to the deprecated <em>&quot;cafile&quot;</em> SSL context
            option if not specified.
           </p>
          </td>
         </tr>

         <tr>
          <td>crl_file</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>Path to a certificate revocation list file.</td>
         </tr>

         <tr>
          <td>pem_file</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Path to a PEM encoded certificate to use for client authentication.
           </p>
           <p class="para">
            Falls back to the deprecated <em>&quot;local_cert&quot;</em> SSL
            context option if not specified.
           </p>
          </td>
         </tr>

         <tr>
          <td>pem_pwd</td>
          <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Passphrase for the PEM encoded certificate (if applicable).
           </p>
           <p class="para">
            Falls back to the deprecated <em>&quot;passphrase&quot;</em> SSL
            context option if not specified.
           </p>
          </td>
         </tr>

         <tr>
          <td>context</td>
          <td><span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span></td>
          <td>
           <p class="para">
            <a href="context.ssl.html" class="link">SSL context options</a> to be used as
            fallbacks for other driver options (as specified). Note that the
            driver does not consult the default stream context.
           </p>
           <p class="para">
            This option is supported for backwards compatibility, but should be
            considered deprecated.
           </p>
          </td>
         </tr>

         <tr>
          <td>weak_cert_validation</td>
          <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
          <td>
           <p class="para">
            Disables certificate validation if <strong><code>TRUE</code></strong>. Defaults to <strong><code>FALSE</code></strong>
           </p>
           <p class="para">
            Falls back to the deprecated <em>&quot;allow_self_signed&quot;</em>
            SSL context option if not specified.
           </p>
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-manager.construct-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <ul class="simplelist">
   <li class="member">Throws <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a> on argument parsing errors.</li>
   <li class="member">Throws <a href="class.mongodb-driver-exception-runtimeexception.html" class="classname">MongoDB\Driver\Exception\RuntimeException</a> if the <code class="parameter">uri</code> format is invalid</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-manager.construct-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>1.5.0</td>
       <td>
        <p class="para">
         <em>&quot;wtimeoutMS&quot;</em> is now always validated and applied to
         the write concern. Previously, the option was ignored if
         <em>&quot;w&quot;</em> was &lt;= 1, since the timeout only applies to
         replication.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.4.0</td>
       <td>
        <p class="para">
         Added the <em>&quot;compressors&quot;</em>,
         <em>&quot;retryWrites&quot;</em>, and
         <em>&quot;zlibCompressionLevel&quot;</em> URI options.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.3.0</td>
       <td>
        <p class="para">
         The <code class="parameter">uriOptions</code> argument now accepts
         <em>&quot;authMechanism&quot;</em> and
         <em>&quot;authMechanismProperties&quot;</em> options. Previously, these
         options were only supported in the <code class="parameter">uri</code> argument.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.2.0</td>
       <td>
        <p class="para">
         The <code class="parameter">uri</code> argument defaults to
         <em>&quot;mongodb://127.0.0.1/&quot;</em>. The default port remains
         <em>27017</em>.
        </p>
        <p class="para">
         Added the <em>&quot;appname&quot;</em> URI option.
        </p>
        <p class="para">
         Added the <em>&quot;allow_invalid_hostname&quot;</em>,
         <em>&quot;ca_file&quot;</em>, <em>&quot;ca_dir&quot;</em>,
         <em>&quot;clr_file&quot;</em>, <em>&quot;pem_file&quot;</em>,
         <em>&quot;pem_pwd&quot;</em>, and
         <em>&quot;weak_cert_validation&quot;</em> driver options.
        </p>
        <p class="para">
         The PHP Streams API is no longer used for socket communication. The
         <em>&quot;connectTimeoutMS&quot;</em> URI option now defaults to 10
         seconds instead of
         <a href="filesystem.configuration.html#ini.default-socket-timeout" class="link">default_socket_timeout</a>
         in previous versions. Additionally, the driver no longer supports all
         <a href="context.ssl.html" class="link">SSL context options</a> via the
         <em>&quot;context&quot;</em> driver option.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.1.0</td>
       <td>
        <p class="para">
         The <code class="parameter">uri</code> argument is optional and defaults to
         <em>&quot;mongodb://localhost:27017/&quot;</em>.
        </p>
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongodb-driver-manager.construct-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="mongowritebatch.add.example.insert">
   <p><strong>Example #1 <span class="function"><strong>MongoDB\Driver\Manager::__construct()</strong></span> basic examples</strong></p>
   <div class="example-contents"><p>Connecting to standalone MongoDB node:</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://example.com:27017"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>
    Connecting to standalone MongoDB node via a Unix domain socket. The socket
    path may include special characters such as slashes and should be encoded
    with <span class="function"><a href="function.rawurlencode.html" class="function">rawurlencode()</a></span>.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">rawurlencode</span><span style="color: #007700">(</span><span style="color: #DD0000">"/tmp/mongodb-27017.sock"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>Connecting to a replica set:</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>Connecting to a sharded cluster (i.e. one or more mongos instances):</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://mongos1.example.com,mongos2.example.com/"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>Connecting to MongoDB with authentication credentials for a particular user and database:</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://myusername:mypassword@example.com/mydatabase"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>


   <div class="example-contents"><p>
    Connecting to MongoDB with authentication credentials for a particular
    user and database, where the username or password includes special
    characters (e.g. <em>@</em>, <em>:</em>,
    <em>%</em>). In the following example, the password string
    <em>myp@ss:w%rd</em> has been manually escaped; however,
    <span class="function"><a href="function.rawurlencode.html" class="function">rawurlencode()</a></span> may also be used to escape URI components
    that may contain special characters.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://myusername:myp%40ss%3Aw%25rd@example.com/mydatabase"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>


   <div class="example-contents"><p>Connecting to MongoDB with X509 authentication:</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"mongodb://example.com/?ssl=true&amp;authMechanism=MONGODB-X509"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;[],<br />&nbsp;&nbsp;&nbsp;&nbsp;[<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"pem_file"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"/path/to/client.pem"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;]<br />);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-manager.construct-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><a href="mongodb.connection-handling.html" class="link">Connection handling and persistence</a></li>
   <li class="member"><a href="https://docs.mongodb.com/manual/reference/connection-string/" class="link external">&raquo;&nbsp;MongoDB Connection String Format</a></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongodb-driver-manager.html">MongoDB\Driver\Manager</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb-driver-manager.executebulkwrite.html">MongoDB\Driver\Manager::executeBulkWrite</a></div>
 <div class="up"><a href="class.mongodb-driver-manager.html">MongoDB\Driver\Manager</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>