phpmongokit / laravel-mongo-odm
PHPMongo Laravel Adapter
Installs: 1 729
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- sokil/php-mongo: 1.*
This package is auto-updated.
Last update: 2024-10-28 02:21:06 UTC
README
Laravel Adapter for PHPMongo ORM
Installation
Add composer dependency:
composer require phpmongokit/laravel-mongo-odm
Register provider in ./config/app.php
:
<?php return [ 'providers' => [ PHPMongoKit\ODM\Adapter\Laravel\MongoDbServiceProvider::class, ], ];
Add configuration of your connections to ./config/mongodb.php
:
<?php return [ 'connections' => [ 'connect1' => [ 'dsn' => 'mongodb://mongodb', ], ], ];
Usage
Get connection pool from service container:
<?php use Psr\Container\ContainerInterface; use Sokil\Mongo\ClientPool; Route::get('/', function (ContainerInterface $container) { /** @var ClientPool $clientPool */ $clientPool = $container->get(ClientPool::class); $connection = $clientPool->get('connect1'); // Instance of Sokil\Mongo\Client });