title: How to get entire MongoDB collection with PHP
body: <p>Using the following code, I can grab a node from a collection:</p>
  
  <pre><code>&lt;?php
  
  $user = "xxxx";
  $pwd = 'xxxx';
  
  if (isset($_POST['needleID'])) {
      $needleID = $_POST['needleID'];
  } else {
      echo "needle ID not set";
  }
  
  //Manager Class
  $connection = new MongoDB\Driver\Manager("mongodb://${user}:${pwd}@localhost:27017");
  
  // Query Class
  $filter = ['id'=&gt; $needleID];
  $query = new MongoDB\Driver\Query($filter);
  
  // Output of the executeQuery will be object of MongoDB\Driver\Cursor class
  $rows = $connection-&gt;executeQuery('DBNAME.DBCOLLECTION', $query);
  
  // Convert rows to Array and send result back to javascript as json
  $rowsArr = $rows-&gt;toArray();
  echo json_encode($rowsArr);
  
  ?&gt;
  </code></pre>
  
  <p>However, what I'm really looking to do is get everything from the DBCOLLECTION.</p>
  
  <p>I'm kind of at a loss on how to do this.  A few searches either go over my head or are for older versions of the PHP driver, such as this one  <a href="https://stackoverflow.com/questions/48744469/fetch-all-data-from-mongodb-collection">fetch all data from mongodb collection</a></p>