Skip to content

Commit

Permalink
[11.x] Add MongoDB to Sail doc (#10020)
Browse files Browse the repository at this point in the history
* Add MongoDB to Sail doc

* Update sail.md

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
GromNaN and taylorotwell authored Nov 12, 2024
1 parent 7102a2d commit f3f131a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sail.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [Executing Node / NPM Commands](#executing-node-npm-commands)
- [Interacting With Databases](#interacting-with-sail-databases)
- [MySQL](#mysql)
- [MongoDB](#mongodb)
- [Redis](#redis)
- [Meilisearch](#meilisearch)
- [Typesense](#typesense)
Expand Down Expand Up @@ -239,6 +240,23 @@ Once you have started your containers, you may connect to the MySQL instance wit

To connect to your application's MySQL database from your local machine, you may use a graphical database management application such as [TablePlus](https://tableplus.com). By default, the MySQL database is accessible at `localhost` port 3306 and the access credentials correspond to the values of your `DB_USERNAME` and `DB_PASSWORD` environment variables. Or, you may connect as the `root` user, which also utilizes the value of your `DB_PASSWORD` environment variable as its password.

<a name="mongodb"></a>
### MongoDB

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 MongoDB 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.

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`. 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, add the credentials to the connection string:

```ini
MONGODB_USERNAME=user
MONGODB_PASSWORD=laravel
MONGODB_URI=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@mongodb:27017
```

For seamless integration of MongoDB with your application, you can install the [official package maintained by MongoDB](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/).

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`.

<a name="redis"></a>
### Redis

Expand Down

0 comments on commit f3f131a

Please sign in to comment.