I'm trying to get all the collection from a database in mongodb with PHP but I didn't find anything on internet useful.
This is what I get so far
$client = new MongoDB\client;
$database = $client->database2;
$collections = $database->listCollections();
foreach ($collections as $collection) {
echo $collection;
}
I'm using listCollections() but doesn't work. I just need to get all data to show it.
This is my folder structure if it helps
This is the output:
Recoverable fatal error: Object of class MongoDB\Model\CollectionInfo could not be converted to string