The team can be divided into parts to make it easier to understand.
The object is connect to the database (MongoDB\Client)
$connection = new MongoDB\Client;
The object is MongoDB\Database to work with a specific database. It uses the magic method __get
, the documentation says:
Selects a database on the server. This magic method is an alias for the selectDatabase() method.
That is, the following commands do the same thing.
$database = $connection->example;
$database = $connection->selectDatabase("example");
Well, now we get the object MongoDB\GridFS\Bucket for file storage in database $database
$bucket = $database->selectGridFSBucket();Perhaps I somehow not so understood, what your problem is - so ask additional questions in the comments