drkp/doctrine-metadata-configuration-factory 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drkp/doctrine-metadata-configuration-factory

Composer 安装命令:

composer require drkp/doctrine-metadata-configuration-factory

包简介

Factory class to create Doctrine 2 ORM Configuration instances.

README 文档

README

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

Factory class to create Doctrine 2 ORM Configuration instances.

Provides simple way to decide what kind of mapping you prefer in your project.

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

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固