创建没有CLI的映射ORM实体? [英] creating mapped ORM Entities without the cli?

查看:92
本文介绍了创建没有CLI的映射ORM实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用zend Framework 2和原理的高级项目。

I'm working on an apiglity project that uses zend framework 2 and the doctrine.

我在zf2项目的local.config.php中包含以下代码:

i included in local.config.php of my zf2 project the following code:

return array(
 'doctrine' => array(
    'connection' => array(
        'orm_default' => array(
            'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
            'params' => array(
                'host'     => 'localhost',
                'port'     => '3306',
                'user'     => '<username>',
                'password' => '<password>',
                'dbname'   => '<db>',
            )
        )
    )
),
);

在我的主模块的配置文件(module.config.php)中,我包含以下代码:

in my main module's configuration file (module.config.php) I included the following code:

 'doctrine' => array(
    'driver' => array(
        __NAMESPACE__ . '_driver' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
        ),
        'orm_default' => array(
            'drivers' => array(
                __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
            )
        )
    )
)

我阅读了以下内容网址:
http://samsonasik.wordpress.com/2013/04/10/zend-framework-2-generate-doctrine-entities-from-existing-database-using-doctrinemodule-and -doctrineormmodule /

I read the following URL: http://samsonasik.wordpress.com/2013/04/10/zend-framework-2-generate-doctrine-entities-from-existing-database-using-doctrinemodule-and-doctrineormmodule/

它表示从中创建实体我的数据库我需要使用 vendor / bin / doctrine-module

and it says that to create Entities from my Database I need to use vendor/bin/doctrine-module.

当我尝试执行教义模块时,出现以下错误:

When I try to execute doctrine-module I get the following error:

PHP Fatal error:  Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.cli' in /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529
Stack trace:
#0 /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/doctrine/doctrine-module/bin/doctrine-module.php(51): Zend\ServiceManager\ServiceManager->get('doctrine.cli')
#1 /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/doctrine/doctrine-module/bin/doctrine-module(4): include('/mnt/storage/ho...')
#2 {main}
thrown in /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 529

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.cli' in /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529
Stack trace:
#0 /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/doctrine/doctrine-module/bin/doctrine-module.php(51): Zend\ServiceManager\ServiceManager->get('doctrine.cli')
#1 /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/doctrine/doctrine-module/bin/doctrine-module(4): include('/mnt/storage/ho...')
#2 {main}
thrown in /mnt/storage/home/ufk/projects/myalcoholist-apigility/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 529

通过阅读以下堆栈溢出问题:
Apigility-如何从ZF2命令行使用Doctrine ORM模块

by reading the following stack overflow question: Apigility - How to use Doctrine ORM Module from ZF2 command line

我了解并不需要教义模块客户端,我应该执行

I understood that the doctrine-module client is not necessary and I should execute

php public/index.php orm:info

以便查看教义的状态。

in order to see the status of doctrine.

执行此操作时,我收到以下错误消息:

when executing this I get the following error message:

[Exception]                                                                                                       
You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or  
mapping files you should check your mapping configuration for errors.                                            

这是因为我创建了Entities文件夹,并且它是空的。

this is because I created the Entities folder and it's empty.

现在的问题是,如果我不能使用教义模块,如何基于数据库创建实体?

now the question is, how do I create Entities based on database if I can't use the doctrine-module ?

推荐答案

'paths'=> array( DIR 。'/../src/'。 NAMESPACE 。'/ Entity')

'paths' => array(DIR . '/../src/' . NAMESPACE . '/Entity')

我不明白这条路径。您能尝试一条简单的路径吗?
例如

I don't understand this path.. Can you try to a simple path? For example

__DIR__.'/../src/YourModule/Entity'

并将您的实体写入src / YouModule / Entity中的YouModule模块

And write your entity into the YouModule module, in src/YouModule/Entity

这篇关于创建没有CLI的映射ORM实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆