MongoDB + PHP leads to ERR_EMPTY_RESPONSE

33 Views Asked by At

Just manage to install MongoDB and use the tutorial from official doc', got an infinite loading with just this :

<?php
use MongoDB\Client;

// Replace the placeholder with your Atlas connection string
$uri = 'mongodb+srv://dev:[email protected]/?retryWrites=true&w=majority;';

// Create a new client and connect to the server
$client = new MongoDB\Client($uri);

So, I maade some search and found another way to connect. (With "mongodb://dev[...]" instead of "mongodb+srv://dev[...]").

Then tried to reach my collection and use it, but, got this beautiful screen : enter image description here

My code look like this :

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use MongoDB\Client;


// Replace the placeholder with your Atlas connection string
$uri = 'mongodb://dev:[email protected]:27017,ac-ierge80-shard-00-01.iupwzop.mongodb.net:27017,ac-ierge80-shard-00-02.iupwzop.mongodb.net:27017/?ssl=true&replicaSet=atlas-7vhjj9-shard-0&authSource=admin&retryWrites=true&w=majority;';

// Create a new client and connect to the server
$client = new MongoDB\Client($uri);

$collection = $client->jvtracker->users;
$cursor = $collection->find(['_id' => 1]);

I did not managed to display some logs / errors, I don't know what's going on here. I disabled Bitdefender (In cas of firewall conflict), changed nothing.

0

There are 0 best solutions below