Skip to content

Commit dff07ca

Browse files
committed
Add MongoDB to Sail doc
1 parent 1ae07b0 commit dff07ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sail.md

+17
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,23 @@ Your application's `docker-compose.yml` file also contains an entry for a [Redis
246246

247247
To connect to your application's Redis database from your local machine, you may use a graphical database management application such as [TablePlus](https://tableplus.com). By default, the Redis database is accessible at `localhost` port 6379.
248248

249+
<a name="mongodb"></a>
250+
### MongoDB
251+
252+
If you chose to install the [MongoDB](https://www.mongodb.com/) service when installing Sail, your application's `docker-compose.yml` file contains an entry for a [MongoDB Atlas Local](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-local-cloud/) container which provides the document database with Atlas features like [Search Indexes](https://www.mongodb.com/docs/atlas/atlas-search/). This container uses a [Docker volume](https://docs.docker.com/storage/volumes/) so that the data stored in your database is persisted even when stopping and restarting your containers.
253+
254+
Once you have started your containers, you may connect to the MongoDB instance within your application by setting your `MONGODB_URI` environment variable within your application's `.env` file to `mongodb://mongodb:27017`. The authentication is disabled by default, but you can set the `MONGODB_USERNAME` and `MONGODB_PASSWORD` environment variables to enable authentication before starting the `mongodb` container. Then you need to set the credentials to the connection string: `mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@mongodb:27017`.
255+
256+
```ini
257+
MONGODB_USERNAME=user
258+
MONGODB_PASSWORD=laravel
259+
MONGODB_URI=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@mongodb:27017
260+
```
261+
262+
For seamless integration of MongoDB with your application, you can install the [package maintained by MongoDB](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/).
263+
264+
To connect to your application's MongoDB database from your local machine, you may use a graphical interface such as [Compass](https://www.mongodb.com/products/tools/compass). By default, the MongoDB database is accessible at `localhost` port `27017`, with authentication only if you modified the `MONGODB_USERNAME` and `MONGODB_PASSWORD` environment variables.
265+
249266
<a name="meilisearch"></a>
250267
### Meilisearch
251268

0 commit comments

Comments
 (0)