PHP stream wrapper for GridFS files in MongoDB
This library provides a PHP stream wrapper for GridFS files in MongoDB. This allows you to access files in GridFS with accessible URLs:
file_put_contents('gridfs://host/database-name/fs-prefix/path/to/file.txt', 'Hello world!');
The wrapper will accept directory separators in the path, but since there is no directory support in GridFS there won't be any real directories.
To use the stream wrapper, include this library in your composer dependencies:
composer require alcaeus/mongodb-gridfs-wrapper:^1.0@dev
Then, in your bootstrap process, register the stream wrapper:
- Stream options (blocking, timeouts, etc.) are not supported yet
- The wrapper currently only works for servers that don't require authentication.
- Directory iterators are not supported (yet)
- File locking is not supported (yet)
- When renaming files, database and bucket must remain the same (for now)