Skip to content

Commit 9c7b6ba

Browse files
committed
Docs review
1 parent 0780822 commit 9c7b6ba

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"illuminate/bus": "< 10.37.2"
4848
},
4949
"suggest": {
50+
"league/flysystem-gridfs": "Filesystem storage in MongoDB with GridFS",
5051
"mongodb/builder": "Provides a fluent aggregation builder for MongoDB pipelines"
5152
},
5253
"minimum-stability": "dev",

docs/filesystems.txt

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.. _laravel-queues:
1+
.. _laravel-filesystems:
22

3-
======
4-
Queues
5-
======
3+
==================
4+
GridFS Filesystems
5+
==================
66

77
.. facet::
88
:name: genre
@@ -14,22 +14,23 @@ Queues
1414
Overview
1515
--------
1616

17-
Using MongoDB to store files can be done using the
18-
`GridFS Adapter for Flysystem <https://flysystem.thephpleague.com/docs/adapter/gridfs/>`__.
17+
You can use the
18+
`GridFS Adapter for Flysystem <https://flysystem.thephpleague.com/docs/adapter/gridfs/>`__
19+
to store large files in MongoDB.
1920
GridFS lets you store files of unlimited size in the same database as your data.
20-
This ensures the integrity of transactions and backups.
2121

2222

2323
Configuration
2424
-------------
2525

26-
Before using the GridFS driver, you will need to install the Flysystem GridFS package via the Composer package manager:
26+
Before using the GridFS driver, install the Flysystem GridFS package through the
27+
Composer package manager by running the following command:
2728

2829
.. code-block:: bash
2930

3031
composer require league/flysystem-gridfs
3132

32-
Configure `Laravel File Storage <https://laravel.com/docs/{+laravel-docs-version+}/filesystem>`__,
33+
Configure `Laravel File Storage <https://laravel.com/docs/{+laravel-docs-version+}/filesystem>`__
3334
to use the ``gridfs`` driver in ``config/filesystems.php``:
3435

3536
.. code-block:: php
@@ -38,14 +39,11 @@ to use the ``gridfs`` driver in ``config/filesystems.php``:
3839
'gridfs' => [
3940
'driver' => 'gridfs',
4041
'connection' => 'mongodb',
41-
'database' => 'files',
42-
'bucket' => 'fs',
43-
'prefix' => '',
44-
'read-only' => false,
45-
'throw' => false,
4642
],
4743
],
4844

45+
You can configure the disk the following settings in ``config/filesystems.php``:
46+
4947
.. list-table::
5048
:header-rows: 1
5149
:widths: 25 75
@@ -60,10 +58,10 @@ to use the ``gridfs`` driver in ``config/filesystems.php``:
6058
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified.
6159

6260
* - ``database``
63-
- Name of the MongoDB database fot the GridFS bucket. Use the database of the connection if not specified.
61+
- Name of the MongoDB database for the GridFS bucket. The driver uses the database of the connection if a database is not specified.
6462

6563
* - ``bucket``
66-
- Name of the GridFS bucket. A database can contain multiple buckets identified by their name. Defaults to ``fs``.
64+
- Name or instance of the GridFS bucket. A database can contain multiple buckets identified by their name. Defaults to ``fs``.
6765

6866
* - ``prefix``
6967
- Specifies a prefix for the name of the files that are stored in the bucket. Using a distinct bucket is recommended
@@ -74,11 +72,11 @@ to use the ``gridfs`` driver in ``config/filesystems.php``:
7472
depending on the configuration of ``throw``. Defaults to ``false``.
7573

7674
* - ``throw``
77-
- If ``true``, exceptions are thrown when an operation cannot be performed. Defaults to ``false``, the operations
78-
return ``true`` in case of succes, ``false`` in case of error.
75+
- If ``true``, exceptions are thrown when an operation cannot be performed. If ``false``,
76+
operations return ``true`` on success and ``false`` on error. Defaults to ``false``.
7977

80-
If you have specific requirements, you can use a factory or a service name to define the bucket. The options
81-
``connection`` and ``database`` are ignored when a ``MongoDB\GridFS\Bucket`` is provided:
78+
You can also use a factory or a service name to create an instance of ``MongoDB\GridFS\Bucket``.
79+
In this case, the options ``connection`` and ``database`` are ignored:
8280

8381
.. code-block:: php
8482

@@ -102,9 +100,9 @@ If you have specific requirements, you can use a factory or a service name to de
102100
Usage
103101
-----
104102

105-
The benefits of using Laravel File Storage facade, is that it provides a common
106-
interface for all the supported file systems. Use the ``gridfs`` disk in the
107-
same way as the ``local`` disk.
103+
A benefit of using Laravel Filesystem is that it provides a common interface
104+
for all the supported file systems. You can use the ``gridfs`` disk in the same
105+
way as the ``local`` disk.
108106

109107
.. code-block:: php
110108

@@ -117,22 +115,28 @@ same way as the ``local`` disk.
117115
echo $disk->get('hello.txt'); // Hello World!
118116

119117
To learn more Laravel File Storage, see
120-
`Laravel File Storage <https://laravel.com/docs/{+laravel-docs-version+}/filesystem>`__.
118+
`Laravel File Storage <https://laravel.com/docs/{+laravel-docs-version+}/filesystem>`__
119+
in the Laravel documentation.
121120

122121
Versioning
123122
----------
124123

125-
In GridFS, file names are metadata to file objects identified by unique MongoDB ObjectID.
126-
There may be more than one file with the same name, they are called "revisions":
124+
In GridFS, file names are metadata in file documents identified by unique
125+
MongoDB ObjectID. If multiple documents share the same file name, they are
126+
considered "revisions" and further distinguished by creation timestamps.
127+
128+
The Laravel MongoDB integration uses the GridFS Flysystem adapter. It interacts
129+
with file revisions in the following ways:
127130

128131
- Reading a file reads the last revision of this file name
129-
- Writing to a file name creates a new revision for this file name
132+
- Writing a file creates a new revision for this file name
130133
- Renaming a file renames all the revisions of this file name
131134
- Deleting a file deletes all the revisions of this file name
132135

133136
The GridFS Adapter for Flysystem does not provide access to a specific revision
134-
of a filename, you must use the :manual:`GridFS API </tutorial/gridfs/>` if you
135-
need to work with revisions.
137+
of a filename. You must use the
138+
`GridFS API <https://www.mongodb.com/docs/php-library/current/tutorial/gridfs/>`__
139+
if you need to work with revisions, as shown in the following code:
136140

137141
.. code-block:: php
138142

0 commit comments

Comments
 (0)