title: Insert data in MongoDB using PHP
body: <p>I am on  <code>php 5.6</code> using <code>WAMP</code> and want to insert a document into MongoDB using PHP. I am doing it in this way: </p>
  
  <pre><code>&lt;?php
  
     require 'vendor/autoload.php';
  
     $con = new MongoDB\Client("mongodb://localhost:27017");
     echo "successfully";
  
     $db = $con-&gt;selectDatabase('DB');
     echo "Selected";
  
     $col = $db-&gt;selectCollection('myCol');
     $document = array( 
        "name" =&gt; "Deny", 
        "password" =&gt; "1234"
     );
  
     $col-&gt;insert($document);
     echo "successfully";
  
     ?&gt;
  </code></pre>
  
  <p>But it is giving the error </p>
  
  <blockquote>
    <p>Fatal error: Call to undefined method MongoDB\Collection::insert() in C:\wamp64\www...</p>
  </blockquote>
  
  <p>I have read <a href="http://php.net/manual/en/mongocollection.insert.php" rel="nofollow">http://php.net/manual/en/mongocollection.insert.php</a> and when I use the same insert function, it doesn't work for me.</p>