For AI agents: a documentation index is available at https://www.mongodb.com/ja-jp/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

MongoDB\GridFS\Bucket::getDatabaseName()

MongoDB\GridFS\Bucket::getDatabaseName()

Returns the name of the database containing this bucket.

function getDatabaseName(): string

The name of the database containing this bucket as a string.

<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket->getDatabaseName());

The output would then resemble:

string(4) "test"