2017 © Pedro Peláez
 

library doctrine-metadata-configuration-factory

Factory class to create Doctrine 2 ORM Configuration instances.

image

drkp/doctrine-metadata-configuration-factory

Factory class to create Doctrine 2 ORM Configuration instances.

  • Friday, September 2, 2016
  • by kpicaza
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Doctrine Metadata configuration Factory

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight, (*1)

Factory class to create Doctrine 2 ORM Configuration instances., (*2)

Provides simple way to decide what kind of mapping you prefer in your project., (*3)

Instalation

composer require drkp/doctrine-metadata-configuration-factory

Simple Usage:

<?php

$mapping = [
   "dbal" => [
       'driver' => 'pdo_sqlite',
       'path' =>  __DIR__ . '/../../../data/db.sqlite'
   ],
   "mappings" => [
       [
           "type" => "annotation",
           "namespace" => "Some\\Namespace",
           "path" => "/path/to/mapping/dir",
       ],
   ],
];

$config = new \DRKP\ZF3Doctrine\MetadataConfigurationFactory(
    $mapping['mappings'],
    $mapping['mappings'][0]['type']
);

$entityManager = \Doctrine\ORM\EntityManager::create(
    $mapping['dbal'],
    $config->make()
);

$repository = $entityManager->getRepository(\Some\Namespace::class);

Advanced usage

Multiple Entity Managers and multiple mapping types

<?php

use DRKP\ZF3Doctrine\MetadataConfigurationFactory;
use Doctrine\ORM\EntityManager;

$mapping = [
   "dbal" => [
       'driver' => 'pdo_sqlite',
       'path' =>  __DIR__ . '/../../../data/db.sqlite'
   ],
   "dbal1" => [
        'host' => '127.0.0.1',
        'port' => '3306',
        'dbname' => '{db}',
        'user' => '{user}',
        'password' => '{pass}',
        'charset' => 'utf8'
   ],
   "mappings" => [
       [
           "type" => "annotation",
           "namespace" => "Some\\Namespace",
           "path" => "/path/to/mapping/dir",
       ],
       [
           "type" => "yaml",
           "namespace" => "Some\\Other\\Namespace",
           "path" => "/path/to/other/mapping/dir",
       ],
   ],
];

$config = new MetadataConfigurationFactory(
    $mapping['mappings'],
    $mapping['mappings'][0]['type']
);

$defaultEntityManager = EntityManager::create(
    $mapping['dbal'],
    $config->make()
);

$config1 = new MetadataConfigurationFactory(
    $mapping['mappings'],
    'yaml'
);

$secondaryEntityManager = EntityManager::create(
    $mapping['dbal1'],
    $config1->make()
);

$repository = $defaultEntityManager->getRepository(\Some\Namespace::class);
$secondaryRepository = $secondaryEntityManager->getRepository(\Some\Other\Namespace::class);

The Versions

02/09 2016

dev-master

9999999-dev

Factory class to create Doctrine 2 ORM Configuration instances.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ddniel16

orm configuration doctrine

02/09 2016

v1.0.1

1.0.1.0

Factory class to create Doctrine 2 ORM Configuration instances.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ddniel16

orm configuration doctrine

01/09 2016

v1.0.0

1.0.0.0

Factory class to create Doctrine 2 ORM Configuration instances.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ddniel16

orm configuration doctrine