I. INTRODUCTION to mongodb installation in the previous section
Installing php mongodb with macos
2: laravel5.1 installation process http://www.golaravel.com/laravel/docs/5.1/#installation
III. laravel5.1 install mongodb
Composer require jenssegers/mongodb
Create a file in app/mongodb. php
<? Php
Namespace App;
Use Jenssegers \ Mongodb \ Model as Eloquent;
Use Illuminate \ Database \ Eloquent \ Model;
Class Mongodb extends Eloquent {
Protected $ connection = 'mongodb ';
Protected $ collection = 'admin ';
}
Add the mongodb link in config/database. php
'Mongodb '=> [
'Driver '=> 'mongodb ',
'Host' => env ('Mo _ DB_HOST ', '192. 168.33.10 '),
'Port' => env ('Mo _ DB_PORT ', 27017 ),
'Database' => env ('Mo _ DB_DATABASE ', 'admin '),
'Username' => env ('Mo _ db_username', 'tank '),
'Password' => env ('Mo _ DB_PASSWORD ', 'test '),
'Options' => array (
'DB' => 'admin' // sets the authentication database required by mongo 3
)
],
Add a route entry in app/Http/routes. php
Route: get ('/mongodb', function (){
$ User = \ App \ Mongodb: all ();
Print_r ($ user );
});
Finally, access http: // localhost/laravel5.1/mongo locally.