承接 cimrie/odm 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cimrie/odm

Composer 安装命令:

composer require cimrie/odm

包简介

Doctrine MongoDB ODM integration with Laravel. Aim to be interoperable with other frameworks.

README 文档

README

This is a package to help integrate The Doctrine MongoDb ODM into any framework of your choice. The only caveat at the moment is that by defining a cache provider, you are declaring that you use Laravel. If you use another framework, you will need to implement your own caching solution.

Laravel Setup

Go to config/app.php and add the service provider to your 'providers' section: CImrie\Odm\OdmServiceProvider::class

Publish the configuration file: php artisan vendor:publish --tag=odm

You can now use the default Document Manager like so:

 <?php
 
 use App\Http\Controllers\Controller;
 use Doctrine\ODM\MongoDB\DocumentManager;
 
 class IndexController extends Controller {
     
     public function index(DocumentManager $documentManager) {
         // code as normal ...
         
         $documentManager->flush(); 
         // etc.
     }
     
 }

General Setup

The package is geared towards laravel, but setup for other frameworks is not impossible, and the package still makes it easier than configuring the ODM by hand.

To generate a Document Manager, you can do the following:

<?php

use CImrie\ODM\DocumentManagerFactory;
use CImrie\ODM\Configuration\OdmConfigurationFactory;
use CImrie\ODM\Configuration\Connections\ConnectionResolver;
use CImrie\ODM\Configuration\MetaData\MetaDataRegistry;
use \CImrie\ODM\Common\Registries\ListenerRegistry;
use CImrie\ODM\Configuration\MetaData\Annotations;

$connectionFactories = [
    new \CImrie\ODM\Configuration\Connections\MongodbConnectionFactory()
];

$config = [
              'mongodb' => [
                    'driver'   => 'mongodb',
                    'host'     => 'localhost',
                    'port'     => 27017,
                    'database' => 'odm',
                    'username' => 'secretuser',
                    'password' => 'secretpass',
                    'options'  => [
                        'database' => 'admin',
                    ],
              ]
          ];

$metaDataDrivers = [
    new Annotations()
];  

$dmFactory = new DocumentManagerFactory(
      new OdmConfigurationFactory(),
      new ConnectionResolver($connectionFactories, $config),
      new MetaDataRegistry([Annotations::class]),
      null, //cache manager
      new ListenerRegistry(),
      null //logger, which can be created by extending CImrie\ODM\Logging\Logger
);

/*
 *  <!------------- WARNING -------------!>
 */
//TODO - THIS PART OF THE DOCS IS NOT COMPLETE

$dmFactory->create(new \CImrie\ODM\Common\Config(
    [
        
    ],
    [
        
    ],
    [
        'database' => [
            'connections' => [
            ]     
        ]
    ]
));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固