It is a blog manager tool made with Laravel 9 & MongoDB.
Assuming your machine meets all requirements - let's process to installation of Metronic Laravel integration (skeleton).
- Open in cmd or terminal app and navigate to this folder
- Run following commands
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan serve
And navigate to generated server link (http://127.0.0.1:8000)
Install the package via Composer:
$ composer require jenssegers/mongodb
In case your Laravel version does NOT autoload the packages, add the service provider to config/app.php
:
Jenssegers\Mongodb\MongodbServiceProvider::class,
You can use MongoDB either as the main database, either as a side database. To do so, add a new mongodb
connection to config/database.php
:
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', 'homestead'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'options' => [
// here you can pass more settings to the Mongo Driver Manager
// see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use
'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
],
],
For multiple servers or replica set configurations, set the host to an array and specify each server host:
'mongodb' => [
'driver' => 'mongodb',
'host' => ['server1', 'server2', ...],
...
'options' => [
'replicaSet' => 'rs0',
],
],
This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.
use Jenssegers\Mongodb\Eloquent\Model;
class Book extends Model
{
//
}
Just like a normal model, the MongoDB model class will know which collection to use based on the model name. For Book
, the collection books
will be used.
To change the collection, pass the $collection
property:
use Jenssegers\Mongodb\Eloquent\Model;
class Book extends Model
{
protected $collection = 'my_books_collection';
}