Error setting up Doctrine + Zend

Asked

Viewed 738 times

0

Hello,

I am trying to configure Doctrine ORM to work with Zend Framework, and when I give the command 'bin/Doctrine-module' appears the following error:

            PHP Fatal error:  Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (DoctrineORMModule) could not be initialized.' in /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:195
    Stack trace:
    #0 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php(169): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
    #1 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php(96): Zend\ModuleManager\ModuleManager->loadModule('DoctrineORMModu...')
    #2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
    #3 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(444): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
    #4 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(205): Zend\EventManage in /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 195

    Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (DoctrineORMModule) could not be initialized.' in /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:195
    Stack trace:
    #0 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php(169): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
    #1 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php(96): Zend\ModuleManager\ModuleManager->loadModule('DoctrineORMModu...')
    #2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
    #3 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(444): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
    #4 /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(205): Zend\EventManage in /var/www/html/zf2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 195

I downloaded the modules through Composer, follow the file:

   {
    "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": "~2.3"
    },

    "minimum-stability" : "dev",
    "require-dev" : {
        "doctrine/doctrine-module": "dev-master",
        "doctrine/data-fixtures": "dev-master"
    },

    "config" : {
        "bin-dir" : "bin"
    }
}

And the autoload configuration is as follows:

  <?php 

    return array(
        'doctrine' => array(
            'connection' => array(
                'orm_default' => array(
                    'driverClass' => 'Doctrine\DBAL\Driver\PDOMysql\Driver',
                    'params' => array(
                        'host'      => 'localhost',
                        'port'      => '3306',
                        'user'      => 'root',
                        'password'  => '',
                        'dbname'    => 'zf2',
                        'driverOptions' => array(
                            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
                        )
                    )
                )
            )
        )
    );
  • Take a look at this blog http://requirecode.blogspot.com.br/2016/06/instalar-o-doctrine-2-no-zend-framework.html. you’ll find what you need about zf2 and Doctrine 2

1 answer

1

Missed, in the composer.json, place the package doctrine/doctrine-orm-module:

"require": {
    "doctrine/doctrine-orm-module": "dev-master",
    "doctrine/doctrine-module": "dev-master",
    "doctrine/data-fixtures": "dev-master"
},

Also, as I believe you will be using the packages in your production application (and not just in development), I put them in the block require of composer.json.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.