Php 在没有cli的情况下创建映射的ORM实体?

Php 在没有cli的情况下创建映射的ORM实体?,php,zend-framework,doctrine-orm,zend-framework2,doctrine,Php,Zend Framework,Doctrine Orm,Zend Framework2,Doctrine,我正在做一个apiglity项目,它使用zend framework 2和学说 我在zf2项目的local.config.php中包含以下代码: return array( 'doctrine' => array( 'connection' => array( 'orm_default' => array( 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',

我正在做一个apiglity项目,它使用zend framework 2和学说

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

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>',
            )
        )
    )
),
);
 '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'
            )
        )
    )
)
我阅读了以下网址:

它说,要从我的数据库中创建实体,我需要使用
vendor/bin/doctor模块

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

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
通过阅读以下堆栈溢出问题:

我理解条令模块客户端不是必需的,我应该执行

php public/index.php orm:info
为了看到学说的地位

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

[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文件夹,它是空的

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

'paths'=>数组(DIR'/../src/'.名称空间'/Entity')

我不明白这条路。。你能试着找到一条简单的路吗? 比如说

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

然后将实体写入YouModule模块,在src/YouModule/entity

hi中,my namespace是模块的名称,因此路径是正确的。问题是目录是空的,因为我没有生成任何实体类。问题是如何生成它们,但你的目录是空的?!您是否创建了表映射?generas实体创建getter和setter并验证映射我没有创建表映射,因为我不想为每个表手动创建表映射。我有很多,正在寻找一种基于我的数据库自动创建它们的方法我不记得DoctrineModule是否支持此流,但您可以尝试使用php public/index.php orm:convert-mapping——从数据库yml/path/to/mapping-path转换为yml(或您的映射驱动程序),我对用户“username”@“localhost”的访问被拒绝(使用密码:是)。我在local.config.php中定义了条令的凭据,为什么它不使用这些信息?