@@ -40,6 +40,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
4040 - [Install Laravel from a Docker Container](#Install-Laravel)
4141 - [Run Artisan Commands](#Run-Artisan-Commands)
4242 - [Use Redis](#Use-Redis)
43+ - [Use Mongo](#Use-Mongo)
4344 - [PHP](#PHP)
4445 - [Install PHP Extensions](#Install-PHP-Extensions)
4546 - [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version)
@@ -92,6 +93,7 @@ docker-compose up nginx mysql redis
9293- PostgreSQL
9394- MariaDB
9495- Neo4j
96+ - MongoDB
9597- Redis
9698- Memcached
9799- Beanstalkd
@@ -208,7 +210,7 @@ docker-compose up -d nginx mysql
208210* Note: the PHP-FPM, Workspace, Application and Data Containers will automatically run.*
209211
210212
211- Supported Containers: ` nginx ` , ` mysql ` , ` redis ` , ` postgres ` , ` mariadb ` , ` neo4j ` , ` memcached ` , ` beanstalkd ` , ` beanstalkd-console ` , ` workspace ` , ` data ` , ` php-fpm ` , ` application ` .
213+ Supported Containers: ` nginx ` , ` mysql ` , ` redis ` , ` postgres ` , ` mariadb ` , ` neo4j ` , ` mongo ` , ` memcached ` , ` beanstalkd ` , ` beanstalkd-console ` , ` workspace ` , ` data ` , ` php-fpm ` , ` application ` .
212214
213215
214216
@@ -512,9 +514,6 @@ Composer update
512514` ` ` bash
513515phpunit
514516` ` `
515- ` ` ` bash
516- laravel new blog
517- ` ` `
518517
519518
520519
@@ -527,7 +526,11 @@ laravel new blog
527526<a name="Use-Redis"></a>
528527# ## Use Redis
529528
530- 1 - First make sure you run the Redis Container with the `docker-compose` command.
529+ 1 - First make sure you run the Redis Container (`redis`) with the `docker-compose up` command.
530+
531+ ` ` ` bash
532+ docker-compose up -d redis
533+ ` ` `
531534
5325352 - Open your Laravel's `.env` file and set the `REDIS_HOST` to your `Docker-IP` instead of the default `127.0.0.1` IP.
533536
@@ -555,7 +558,7 @@ CACHE_DRIVER=redis
555558SESSION_DRIVER=redis
556559` ` `
557560
558- 4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first.
561+ 4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer :
559562
560563` ` ` bash
561564composer require predis/predis:^1.0
@@ -571,6 +574,59 @@ composer require predis/predis:^1.0
571574
572575
573576
577+ <br>
578+ <a name="Use-Mongo"></a>
579+ # ## Use Mongo
580+
581+ 1 - First make sure you run the MongoDB Container (`mongo`) with the `docker-compose up` command.
582+
583+ ` ` ` bash
584+ docker-compose up -d mongo
585+ ` ` `
586+
587+
588+ 2 - Add the MongoDB configurations to the `config/database.php` config file :
589+
590+ ` ` ` php
591+ 'connections' => [
592+
593+ 'mongodb' => [
594+ 'driver' => 'mongodb',
595+ 'host' => env('DB_HOST', 'localhost'),
596+ 'port' => env('DB_PORT', 27017),
597+ 'database' => env('DB_DATABASE', 'database'),
598+ 'username' => '',
599+ 'password' => '',
600+ 'options' => [
601+ 'database' => '',
602+ ]
603+ ],
604+
605+ // ...
606+
607+ ],
608+ ` ` `
609+
610+ 3 - Open your Laravel's `.env` file and update the following variables :
611+
612+ - set the `DB_HOST` to your `Docker-IP`.
613+ - set the `DB_PORT` to `27017`.
614+ - set the `DB_DATABASE` to `database`.
615+
616+
617+ 4 - Finally make sure you have the `jenssegers/mongodb` package installed via Composer and its Service Provider is added.
618+
619+ ` ` ` bash
620+ composer require jenssegers/mongodb
621+ ` ` `
622+ More details about this [here](https://github.com/jenssegers/laravel-mongodb#installation).
623+
624+ 5 - Test it :
625+
626+ - First let your Models extend from the Mongo Eloquent Model. Check the [documentation](https://github.com/jenssegers/laravel-mongodb#eloquent).
627+ - Enter the Workspace Continer `docker exec -it laradock_workspace_1 bash`.
628+ - Migrate the Database `php artisan migrate`.
629+
574630
575631
576632
0 commit comments