Skip to content

Commit f3f131a

Browse files
[11.x] Add MongoDB to Sail doc (#10020)
* Add MongoDB to Sail doc * Update sail.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 7102a2d commit f3f131a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

sail.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Executing Node / NPM Commands](#executing-node-npm-commands)
1414
- [Interacting With Databases](#interacting-with-sail-databases)
1515
- [MySQL](#mysql)
16+
- [MongoDB](#mongodb)
1617
- [Redis](#redis)
1718
- [Meilisearch](#meilisearch)
1819
- [Typesense](#typesense)
@@ -239,6 +240,23 @@ Once you have started your containers, you may connect to the MySQL instance wit
239240

240241
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.
241242

243+
<a name="mongodb"></a>
244+
### MongoDB
245+
246+
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.
247+
248+
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:
249+
250+
```ini
251+
MONGODB_USERNAME=user
252+
MONGODB_PASSWORD=laravel
253+
MONGODB_URI=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@mongodb:27017
254+
```
255+
256+
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/).
257+
258+
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`.
259+
242260
<a name="redis"></a>
243261
### Redis
244262

0 commit comments

Comments
 (0)