Install library
$ composer require makasim/yadm-bundle "mikemccabe/json-patch-php:dev-master as 0.1.1"
Register the bundle
<?php
# /app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new \Makasim\Yadm\Bundle\YadmBundle(),
];
return $bundles;
}
}
yadm:
mongo_uri: 'mongodb://mongo:27017/db_name'
models:
category:
class: 'Acme\Model\Category'
collection: 'category'
product:
class: 'Acme\Model\Product'
collection: 'product'
hydrator: 'app.product.hydrator'
In your code you can get the storage from registry:
<?php
$registry = $container->get('yadm');
$productStorage = $registry->getStorage('Acme\Model\Category');
MIT