Skip to content

Commit

Permalink
Move doc to a dedicated page
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed May 24, 2024
1 parent 75897e0 commit cc6357e
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 82 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ to interact with your storage.
3. [Interacting with FTP and SFTP servers](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/3-interacting-with-ftp-and-sftp-servers.md)
4. [Using a lazy adapter to switch storage backend using an environment variable](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/4-using-lazy-adapter-to-switch-at-runtime.md)
5. [Creating a custom adapter](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/5-creating-a-custom-adapter.md)
6. [MongoDB GridFS](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/6-gridfs.md)

* [Security issue disclosure procedure](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/A-security-disclosure-procedure.md)
* [Configuration reference](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/B-configuration-reference.md)
Expand Down
81 changes: 0 additions & 81 deletions docs/2-cloud-storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,87 +155,6 @@ flysystem:
bucket: '%env(SCALEWAY_SPACES_BUCKET)%'
```
## MongoDB GridFS
```
composer require league/flysystem-gridfs
```

If you use `DoctrineMongoDBODMBundle`, the

```yaml
# config/packages/flysystem.yaml

flysystem:
storages:
users.storage:
adapter: 'gridfs'
options:
# Name of a Doctrine MongoDB ODM connection
doctrine_connection: 'default'
# Use the default DB from the Doctrine MongoDB ODM configuration
database: ~
bucket: 'fs'
```
You can also use the full configuration:
```yaml
# config/packages/flysystem.yaml

flysystem:
storages:
users.storage:
adapter: 'gridfs'
options:
# MongoDB client configuration
mongodb_uri: '%env(MONGODB_URI)%'
mongodb_uri_options: []
mongodb_driver_options: []
# Database name is required
database: '%env(MONGODB_DB)%'
bucket: 'fs'
```
```dotenv
# .env

MONGODB_URI=mongodb://127.0.0.1:27017/
MONGODB_DB=flysystem
```

For a more advanced configuration, create a service [`MongoDB\GridFS\Bucket`](https://www.mongodb.com/docs/php-library/current/tutorial/gridfs/):

```yaml
# config/packages/flysystem.yaml

services:
mongodb_client:
class: 'MongoDB\Client'
arguments:
- '%env(MONGODB_URI)%'

mongodb_database:
class: 'MongoDB\Database'
factory: ['mongodb_client', 'selectDatabase']
arguments: ['%env(MONGODB_DB)%']

mongodb_gridfs_bucket:
class: 'MongoDB\GridFS\Bucket'
factory: ['@mongodb_database', 'selectGridFSBucket']
arguments:
- disableMD5: true
bucketName: fs

flysystem:
storages:
users.storage:
adapter: 'gridfs'
options:
# Service name
bucket: 'mongodb_gridfs_bucket'
```
## Next
[Interacting with FTP and SFTP servers](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/3-interacting-with-ftp-and-sftp-servers.md)
88 changes: 88 additions & 0 deletions docs/6-gridfs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# MongoDB GridFS

GridFS stores files in a MongoDB database.

Install the GridFS adapter:

```
composer require league/flysystem-gridfs
```

## With `doctrine/mongodb-odm-bundle`

For applications that uses Doctrine MongoDB ODM, set the `doctrine_connection` name to use:

```yaml
# config/packages/flysystem.yaml

flysystem:
storages:
users.storage:
adapter: 'gridfs'
options:
# Name of a Doctrine MongoDB ODM connection
doctrine_connection: 'default'
# Use the default DB from the Doctrine MongoDB ODM configuration
database: ~
bucket: 'fs'
```
## Full configuration
To initialize the GridFS bucket from configuration, set the `mongodb_uri` and `database` options, others are optional.

```yaml
# config/packages/flysystem.yaml
flysystem:
storages:
users.storage:
adapter: 'gridfs'
options:
# MongoDB client configuration
mongodb_uri: '%env(MONGODB_URI)%'
mongodb_uri_options: []
mongodb_driver_options: []
# Database name is required
database: '%env(MONGODB_DB)%'
bucket: 'fs'
```

```dotenv
# .env
MONGODB_URI=mongodb://127.0.0.1:27017/
MONGODB_DB=flysystem
```

## With bucket service

For a more advanced configuration, create a service for
[`MongoDB\GridFS\Bucket`](https://www.mongodb.com/docs/php-library/current/tutorial/gridfs/):

```yaml
# config/packages/flysystem.yaml
services:
mongodb_client:
class: 'MongoDB\Client'
arguments:
- '%env(MONGODB_URI)%'
mongodb_database:
class: 'MongoDB\Database'
factory: ['mongodb_client', 'selectDatabase']
arguments: ['%env(MONGODB_DB)%']
mongodb_gridfs_bucket:
class: 'MongoDB\GridFS\Bucket'
factory: ['@mongodb_database', 'selectGridFSBucket']
flysystem:
storages:
users.storage:
adapter: 'gridfs'
options:
# Service name
bucket: 'mongodb_gridfs_bucket'
```
1 change: 0 additions & 1 deletion src/Adapter/Builder/GridFSAdapterDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace League\FlysystemBundle\Adapter\Builder;

use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle;
use Doctrine\ODM\MongoDB\DocumentManager;
use League\Flysystem\GridFS\GridFSAdapter;
use MongoDB\Client;
Expand Down

0 comments on commit cc6357e

Please sign in to comment.