PHP code example of phpmongokit / laravel-mongo-odm

1. Go to this page and download the library: Download phpmongokit/laravel-mongo-odm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpmongokit / laravel-mongo-odm example snippets




return [
    'providers' => [
        PHPMongoKit\ODM\Adapter\Laravel\MongoDbServiceProvider::class,
    ],
];



return [
    'connections' => [
        'connect1' => [
            'dsn' => 'mongodb://mongodb',
        ],
    ],
];



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
});