Giter VIP home page Giter VIP logo

doctrinemongoodmmodule's Introduction

Doctrine MongoDB ODM Module for Laminas

Build Status Code Coverage Latest Stable Version Total Downloads

The DoctrineMongoODMModule leverages DoctrineModule and integrates Doctrine MongoDB ODM with Laminas quickly and easily. The following features are intended to work out of the box:

  • MongoDB support
  • Multiple document managers
  • Multiple connections
  • Support for using existing Mongo connections
  • Doctrine CLI support

Installation

Run the following to install this library using Composer:

composer require doctrine/doctrine-mongo-odm-module

Documentation

Please check the documentation on the Doctrine website for more detailed information on features provided by this component. The source files for the documentation can be found in the docs directory.

doctrinemongoodmmodule's People

Contributors

adamh114 avatar adrienbrault avatar alcaeus avatar andreasrs avatar bilge avatar dorongutman avatar driehle avatar fabiocarneiro avatar gianarb avatar greg0ire avatar jaepilcyan avatar jhuet avatar jmikola avatar koubas avatar levofski avatar malarzm avatar matwright avatar michaelmoussa avatar michalbundyra avatar midnightdesign avatar ocramius avatar prolic avatar rieschl avatar romankonz avatar senseexception avatar smolnikov avatar spiffyjr avatar superdweebie avatar tomhanderson avatar vbarinov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrinemongoodmmodule's Issues

Only odm_default keys actually work

Using any keys other than odm_default fails with a fatal exception when trying to locate the matching service name.

exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.configuration.dev' in ZendFramework-minimal-2.0.0/library/Zend/ServiceManager/ServiceManager.php:420

    [
        'configuration' => [
            'odm_default' => [
                'generate_proxies'   => false,
                'generate_hydrators' => false,
            ],
            'dev' => [
                'generate_proxies'   => true,
                'generate_hydrators' => true,
            ]
        ]

...

        'documentmanager' => [
            'odm_default' => [
                'configuration' => 'odm_default', //OK
            ]
        ],

-OR-

        'documentmanager' => [
            'odm_default' => [
                'configuration' => 'dev', //Exception
            ]
        ],

...

    ]

Class 'DoctrineMongoODMModule\Hydrator\EntityHydrator' not found

It looks to me like a race condition. Application has permission to write into cache directory and file is actually there, but probably not at the moment when error occurs. This is happening from time to time and it's not related with deployment.

E_ERROR: Class 'DoctrineMongoODMModule\Hydrator\ShortenDocumentShortyHydrator' not found
Sample stack trace
…dor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php (154)
…dor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php (419)
…ps/shorten/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/UnitOfWork.php (2549)
…doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php (532)
…doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php (394)
…en/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/DocumentRepository.php (175)
…home/webapps/shorten/module/Shorten/src/Shorten/Controller/IndexController.php (57)
…amework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php (83)
in Zend\Mvc\Controller\AbstractActionController::onDispatch called at ? (?)
…/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php (468)
…/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php (207)
…zendframework/zendframework/library/Zend/Mvc/Controller/AbstractController.php (117)
…orten/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php (114)
in Zend\Mvc\DispatchListener::onDispatch called at ? (?)
…/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php (468)
…/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php (207)
…ps/shorten/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php (309)
in Zend\Mvc\Application::run called at /path/shorten/public/index.php (12)

Any ideas why is this happening?

improve ZendDeveloperToolbar integration

$queryBuilder->find(...)->limit(1)->skip(1) is shown as 3 queries.

A note is shown that the integration has to be improved, so i think it's known that there are problems with it.

Paginator adapter ignore sorting

$query = $this->createQueryBuilder()->find()->sort($sort)->getQuery();

$adapter = new PaginatorAdapter($query->execute());

$orders = new Paginator($adapter);
$orders->setCurrentPageNumber($page)
    ->setItemCountPerPage($limit);

These code not works as expected. If I change DoctrineMongoODMModule\Paginator\Adapter\DoctrinePaginator to these everything works:

    public function getItems($offset, $itemCountPerPage)
    {
//        $cursor = clone $this->cursor;
        $cursor = $this->cursor;
//        $cursor->recreate();
        $cursor->skip($offset);
        $cursor->limit($itemCountPerPage);

        return $cursor;
    }

Can't enable ZendDeveloperTools

I created 2 MongoODM connections but I didn't manage to activate their monitoring in the ZDT.

config/autoload/doctrine.global.php:

return array(
    'doctrine' => array(
        'mongo_logger_collector' => array(
            'odm_default' => array(),
            'odm_api' => array(),
        ),

        // zendframework/zend-developer-tools specific settings
        'view_manager' => array(
            'template_map' => array(
                'zend-developer-tools/toolbar/doctrine-odm'
                => 'module/Internal/view/zend-developer-tools/toolbar/doctrine-odm.phtml',
            ),
        ),
    ),
);

config/autoload/zdt.global.php:

return array(
    'zenddevelopertools' => array(
        'profiler' => array(
            'collectors' => array(
                  'db' => false, 
                  'odm_default' => 'doctrine.mongo_logger_collector.odm_default',
                  // 'odm_api' => 'doctrine.mongo_logger_collector.odm_api',
            ),
        ),
        'toolbar' => array(
            'entries' => array(
                  'odm_default' => 'zend-developer-tools/toolbar/doctrine-odm',
                  // 'odm_api'     => 'zend-developer-tools/toolbar/doctrine-odm',
            ),
        ),
    ),
);

I obtain this screenshot if I leave the second connection commented. I get an error if I uncomment it :(

Thanks for your help.

screenshot 2013-06-01 at 12 28 18

error with composer installer

output :

sina@SINA-PC:/var/www/yehja$ php composer.phar install
Installing dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for doctrine/doctrine-mongo-odm-module dev-master -> satisfiable by doctrine/doctrine-mongo-odm-module dev-master.
    - doctrine/doctrine-mongo-odm-module dev-master requires doctrine/mongodb-odm dev-master -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.```

Remove dead test code

DoctrineMongoODMModuleTest\BaseTest needs to be removed. (I thought it was in the last PR, but it's still there)

Tag 0.8.1

There was a BC fix for the Doctrine CLI and it's sitting in master. @superdweebie you should tag a new release for this BC fix.

Change composer.json to allow different branches of zf2

A the moment this module won't install with composer and zendframework/zendframework develop-dev. There should be some way to allow use of this module with the development version of zf2. Could/should we remove zf2 from the requires list? Or, do I have to go through the mess of overriding the repository in my root composer.json?

driver example ?

can you please provide an example of driver configuration for reading annotation of documents in Application/src/Application/Document/....

thanks

Reference document failed to be hydrated

Hello and Good day,
First My appreciation to all those who make this project tick. More strength and wisdom to you.
I am experiencing an issue here:
I have a form which has a fieldset say 'A'. That fieldset 'A' also has another fieldset say 'B' which contains a select element that is being populated via the DoctrineModule's selectObject.

According to advised principles, every model/document should have its own fieldset, fieldset A has a document 'DA' and fieldset 'B' a document 'DB'. There is also a ReferenceOne relationship between DA and DB .i.e. DA has a property that references one DB, now this is the problem.

When i submit the form, I get a badMethodCallException.
Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::getAssociationTargetClass($assocName) is not implemented yet.
which is obvious.

Let me say that I am using the DoctrineHydrator in the form and fieldsets,
like this
$this->setHydrator(new \DoctrineModule\Stdlib\Hydrator\DoctrineObject($documentManager));
followed by (in the filedsets alone)
$this->setObject($document);

Let me say that am new to this so i need to ask what can be done?

Thanks

AnnotationBuilder not exist ?

Hi there,
I'm wondering why DoctrineMongoODMModule has no form AnnotationBuilder like:

DoctrineORMModule\Form\Annotation\AnnotationBuilder

'dbname' in the configuration file is not forwarded on

I've set a dbname in the module.doctrine-mongo-odm.local.php file, and while the $connectionString in https://github.com/doctrine/DoctrineMongoODMModule/blob/master/src/DoctrineMongoODMModule/Service/ConnectionFactory.php#L53 is correct (equals to the value I entered in the dbname param in the configuration file), the value of $this->config->getDefaultDB(); in https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L308 is empty, which causes the $db variable in https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L309 to be 'doctrine'.

EDIT: It appears I've missed the configuration key ['doctrine']['configuration']['odm_default']['default_db'], which indeed controls the actual db in https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L308.

However, this means there are two different places in the same configuration file for setting the name of the db.
Shouldn't this be controlled from the same place? Or perhaps using a variable in the beginning of the configuration and using that in the two different keys ?

How to get data from multiple collection in loop

when i try to get data from multiple collection code giving me data only from first collection
i.e collection are project_0, project_1, project_2, project_3

for($i = 0; $i <= 3; $i++){
$dm->getClassMetadata('\Application\Document\Product')->setCollection('product_'. $i);
$record = $dm->getRepository('\Application\Document\Product')->findOneBy($condition);
}

i tried clear flush but noting is working please let me know right way to do it

Increment doctrine-module version to 0.9

"doctrine/doctrine-module": "0.8.*"

Is it possible to increment the required doctrine module version to 0.9 since doctrine ORM requires this version too. So it's impossible to install both without a custom fork or hack.

query builder pagination not working

Hello and Good day,
First my appreciation for the work and effort that has been put in to make this module.

Please i have an issue with pagination using skip() and limit() in the query builder. it returns all documents instead of the filtered ones.

$this->createQueryBuilder()
->limit($limit)
->skip($skip)
->getQuery()
->execute();

this is called from a repository class which extend the normal mongodb document repository.
am using doctrine mongo odm module 0.7.2

Thanks and looking forward to your response

I try to install this module in my zend framework and getting folloing error

Problem 1
- doctrine/mongodb 1.0.3 requires ext-mongo >=1.2.12,<1.5-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.2 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.1 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA3 requires ext-mongo >=1.3.1,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA2 requires ext-mongo >=1.2.12,<1.3-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA1 requires ext-mongo * -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/doctrine-mongo-odm-module dev-master requires doctrine/mongodb-odm ~1.0.0-beta9@dev -> satisfiable by doctrine/mongodb-odm[1.0.0-BETA9].
- doctrine/mongodb-odm 1.0.0-BETA9 requires doctrine/mongodb 1.0.* -> satisfiable by doctrine/mongodb[1.0.0, 1.0.0-BETA1, 1.0.0-BETA2, 1.0.0-BETA3, 1.0.1, 1.0.2, 1.0.3].
- Installation request for doctrine/doctrine-mongo-odm-module dev-master -> satisfiable by doctrine/doctrine-mongo-odm-module[dev-master]

Paginator does not work with Mongodb ODM > 1.0.0-beta10@dev

Hi,
DoctrineMongoODMModule/Paginator/Adapter/DoctrinePaginator
does not work since version mongodb-odm:1.0.0-beta10

This is due to a change in the Doctrine/ODM/MongoDB/DocumentRepository, the "findBy" function does not return a MongoODM/Cursor but an Array.

In BETA 9

/**
     * Finds documents by a set of criteria.
     *
     * @param array        $criteria Query criteria
     * @param array        $sort     Sort array for Cursor::sort()
     * @param integer|null $limit    Limit for Cursor::limit()
     * @param integer|null $skip     Skip for Cursor::skip()
     * @return Cursor
     */
    public function findBy(array $criteria, array $sort = null, $limit = null, $skip = null)
    {
        return $this->uow->getDocumentPersister($this->documentName)->loadAll($criteria, $sort, $limit, $skip);
    }

In BETA 10

/**
     * Finds documents by a set of criteria.
     *
     * @param array        $criteria Query criteria
     * @param array        $sort     Sort array for Cursor::sort()
     * @param integer|null $limit    Limit for Cursor::limit()
     * @param integer|null $skip     Skip for Cursor::skip()
     *
     * @return array
     */
    public function findBy(array $criteria, array $sort = null, $limit = null, $skip = null)
    {
        return $this->getDocumentPersister()->loadAll($criteria, $sort, $limit, $skip)->toArray(false);
    }

There is a solution to use the latest version of mongo-ODM (ex: BETA11)?

Module order matters in Application config

At present modules must be placed in this order in ZF2 application config:
'DoctrineMongoODMModule', 'DoctrineModule',
If placed in the reverse order, fatal error occurs. This is due to a submodule of DoctrineModuleODMModule using an old version of doctrine-common that is not compatible with DoctrineModule.

Create hydrators for using MongoODM collection type with ZF2 form collection

Currently it's not possible to use ODM collections (http://doctrine-mongodb-odm.readthedocs.org/en/latest/reference/annotations-reference.html#collection) with zf2 form collection, since it only works with collections of objects rather than plain values (collection of strings, etc).
It would be great to have an ability to use ODM data types with forms.

Related to this issue: http://stackoverflow.com/questions/24940032/doctrine-odm-collection-zf2-form-collection?rq=1

Getting an Invalid instantiator message

Just wanted to know what I need to do to get this thing working in a zf2 app... I dont know anything about this config/autoload folder... and I have tried sticking this into my module.config array... nothing seems to be working on this. $this->getLocator()->get('mongo_dm'); gives me that error.

Clean up messy tests

The tests are messy and kludgy. They need a tidy up. I'll do it in the next week or so, if nobody beats me to it.

Errors on doctrine when trying to install phpunit

C:\wamp\bin\php\php5.3.9\php.exe C:\wamp\www\myapp\composer.phar require     phpunit/phpunit:3.7.24 -n --no-progress

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: remove doctrine/doctrine-module 0.8.x-dev
- don't install doctrine/doctrine-module 0.8.x-dev|install doctrine/doctrine-module dev-master
- Installation request for doctrine/doctrine-module == 0.8.9999999.9999999-dev -> satisfiable by doctrine/doctrine-module[0.8.x-dev].
- Conclusion: remove doctrine/common 2.5.x-dev
- doctrine/doctrine-module dev-master requires doctrine/common >=2.3,<2.5-dev -> satisfiable by doctrine/common[2.3.0, 2.3.x-dev, 2.4.0-RC1, 2.4.0-RC2, 2.4.0-RC3, 2.4.0-RC4, 2.4.x-dev, v2.4.0, v2.4.1].
- Can only install one of: doctrine/common[2.5.x-dev, 2.3.0].
- Can only install one of: doctrine/common[2.5.x-dev, 2.3.x-dev].
- Can only install one of: doctrine/common[2.5.x-dev, 2.4.0-RC1].
- Can only install one of: doctrine/common[2.5.x-dev, 2.4.0-RC2].
- Can only install one of: doctrine/common[2.5.x-dev, 2.4.0-RC3].
- Can only install one of: doctrine/common[2.5.x-dev, 2.4.0-RC4].
- Can only install one of: doctrine/common[2.5.x-dev, 2.4.x-dev].
- Can only install one of: doctrine/common[v2.4.0, 2.5.x-dev].
- Can only install one of: doctrine/common[v2.4.1, 2.5.x-dev].
- Installation request for doctrine/common == 2.5.9999999.9999999-dev -> satisfiable by doctrine/common[2.5.x-dev].

Here is my composer.json:

{
    "minimum-stability": "dev",
    "name": "zendframework/kasjroet",
    "description": "MyApp",
        "license": "BSD-3-Clause",
        "keywords": [
        "framework",
        "zf2",
        "DoctrineORMModule",
        "DoctrineModule"
    ],
    "require":{
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.*",
        "zendframework/Zend-developer-tools": "dev-master",
        "zendframework/ZendPdf": "dev-master",
       "doctrine/doctrine-module": "dev-master",
       "doctrine/doctrine-orm-module": "dev-master",
       "gedmo/doctrine-extensions": "dev-master",
       "zf-commons/zfc-user": "dev-master",
       "zf-commons/zfc-user-doctrine-orm": "dev-master",
        "doctrine/data-fixtures": "dev-master"
    }
}

I'm not sure what I should do here.
Any advice?

Master broken with sort() error

Just noticed that tests are not passing in master. Something wrong with sort().

I haven't touched that area of the code, and I know there was some talk about it a few months ago. Does someone know what's going on from a quick glance, or do I need to go digging myself?

ping @Ocramius @bakura10 @spiffyjr

[RuntimeException] Failed to clone https://github.com/doctrine/DoctrineMongoODMModule.git

Updating dependencies (including require-dev)

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]

Upgrade doctrine/mongodb-odm version

Composer requires version:

 "doctrine/mongodb-odm": "~1.0.0-beta9@dev",

Currently version 1.0.0-BETA11 is already tagged.
Is it possible to use the latest ODM beta, or will this break stuff?

Doctrine ODM Zend 2 Module - MongoHQ - Failed to connect to: mongodb - unauthorized db:doctrine lock type:

Hi All. I am struggling to get a connection to my mongo db to work. I have and account with mongohq. I am using Zend 2 and the mongo odm module available on github. I have tried:

 'connection' => array(
            'odm_default' => array(
                'server'    => 'flame.mongohq.com',
                'port'      => '<port>',
                'user'      => '<user>',
                'password'  => '<password>',
                'dbname'    => '<database>',
            ),
        ),

The result for that is:

flame.mongohq.com:27058: unauthorized db:doctrine lock type:-1 client:[CLIENT IP

So I tried:

'server' => 'mongodb://flame.mongohq.com/27058'

and the result for that is

Failed to connect to: mongodb:0: No such file or directory

I also tried defining the entire string and passing it to the server variable , i.e.

$mongoDns = sprintf('mongodb://%s:%s@%s:%s/%s',
    '<user>',
    '<password>',
    'flame.mongohq.com',
    '27058',
    '<database>'
);

I get the same "failed to connect" result.

I also tried to pass the string above to the MongoClient function and then pass that object to the server variable. result

Failed to connect to: flame.mongohq.com:27058:27058: Couldn't get host info for flame.mongohq.com:27058

So, it looks to me like there is a bug somewhere. But I cant figure out where.

I tried the connection string and MongoClient function independently (not using the Zend 2 Module or Doctrine) and it connected fine.

Any thoughts? Is there anyone that has successfully connected to a host requiring authentication using the Mongo-ODM Zend 2 module?

Error updating with composer

Running an update with composer and getting this error:

doctrine/doctrine-mongo-odm-module dev-master requires doctrine/doctrine-module 0.9.* -> no matching package found.

This was working just fine a few days ago.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.