makasim/yadm-bundle

Installs: 1 405

Dependents: 1

Suggesters: 0

Stars: 7

Watchers: 3

Forks: 1

Open Issues: 0

Type:symfony-bundle

0.4.0 2018-06-11 09:26 UTC

README

Install

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

Configure

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'

Usage

In your code you can get the storage from registry:

<?php

$registry = $container->get('yadm');

$productStorage = $registry->getStorage('Acme\Model\Category');

Licence

MIT