0
votes

I'm trying to integrate the DoctrineORMModule module with ZF2 RC2 but I'm having issues. My ./composer.json is as follows and php composer.phar update is running fine:

"require": {
    "php": ">=5.3.3",
    "doctrine/data-fixtures": "dev-master",
    "doctrine/doctrine-module": "dev-master",
    "doctrine/orm": ">2.2,<2.4-dev",
    "doctrine/dbal": ">2.2,<2.4-dev",
    "doctrine/migrations": "dev-master",
    "zendframework/zendframework": "dev-master#a59928a3a37e420193939f9799ece27fb39bb84e"
},
"autoload": {
    "psr-0": {
        "DoctrineORMModule": "src/",
        "DoctrineORMModuleTest": "tests/"
    }
}

However one of the modules added to ./application/application.config.php is causing problems:

'modules' => array(
    'Application',
    'DoctrineModule',    // WORKS FINE
    'DoctrineORMModule', // 'Module (DoctrineORMModule) could not be initialized.'
),

This is confirmed when I issue the ./vendor/bin/doctrine-module command:

PHP Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (DoctrineORMModule) could not be initialized.' in ./vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:139

If I search my vendor directory for Doctrine namespaces I can find namespaces for DoctrineModule (grep "namespace DoctrineModule" -R ./vendor finds things) but not DoctrineORMModule (grep "namespace DoctrineORMModule" -R ./vendor doesn't).

What am I missing in order to integrate DoctrineORMModule with ZF2 RC2?

2
As this already has an accepted answer, i will leave this here. For windows users i've blogged about some specific problems installing Doctrine 2 for ZF2 right here > samminds.com/2012/07/install-doctrine-2-for-zend-framework-2Sam

2 Answers

3
votes

You forgot to require "doctrine/doctrine-orm-module"

The DoctrineModule contains a bunch of abstract classes to give the ORM/MongoDB and other databases the same API.

Read more about installation DoctrineORMModule here https://github.com/doctrine/DoctrineORMModule

0
votes

I think you just need add

"doctrine/DoctrineORMModule": "dev-master"

like this

{
    "name": "zendframework/skeleton-application",
    "description": "Skeleton Application for ZF2",
    "license": "BSD-3-Clause",
    "keywords": [
        "framework",
        "zf2"
    ],
    "homepage": "http://framework.zend.com/",
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "dev-master#a59928a3a37e420193939f9799ece27fb39bb84e",
        "doctrine/DoctrineORMModule" : "dev-master"
    }
}

then run

php composer.phar update