问题描述
我从阿根廷写作,原谅我的英文小说。我在模块 c> ZfcUser 和 zfcuserDoctrineORM 中遇到问题。我需要将它们整合到我的项目中。我正在使用Zend框架2,doctrine 2.3和postgreSQL,这是我第一次使用这些工具。因此,我有很多事情并不统治,我的所有模块都包含在我的 /config/application.config.php 中,我的连接被配置在我的数据库中 /config/autoload/local.phpLocal.php
返回数组(
'doctrine'=> array(
'connection'=> array (
'orm_default'=> array(
'driverClass'=>'Doctrine\DBAL\Driver\PDOPgSql\Driver',
'params'=> array(
'host'=>'localhost',
'port'=>'5432',
'user'=>'postgres',
'password'=>'postgres'
'dbname'=>'Ministerio',
)
)
)
)
);
application.config.php
return array(
'modules'=> array(
'Application',
'DoctrineModule',
'DoctrineORMModule ',
'Reeser',//我的模块名称
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineORM',
)
'module_listener_options'=> array(
'config_glob_paths'=> array(
'config / autoload / {,*。} {global,local} .php',
) ,
'module_paths'=> array(
'./module',
'./vendor',
),
),
);
为了映射我的数据库,我使用注释与原则,我有我自己的实体用户在我的模块中生成
我添加了配置档案 zfcuser.global.php 和 zfcuserdoctrineorm.global。 php 在我的自动加载目录,但我不知道如何配置它们,以便归档识别我的实体。
进入 zfcuser .global.php
'zend_db_adapter'=>'Zend\Db\Adapter\Adapter',//应该这个评论吗?
'user_entity_class'=>'Reeser\Entity\User',
'login_redirect_route'=>'Reeser / index / index.phtml',
return array(
'zfcuser'=> $ settings,//我如何配置这个代码?
'service_manager'=> array(
'aliases'=> array b $ b'zfcuser_zend_db_adapter'=>(isset($ settings ['zend_db_adapter']))
$ settings ['zend_db_adapter']:'Zend\Db\Adapter\Adapter',
),
),
);
进入 zfcuserdoctrineorm.global.php
pre
return array(
'doctrine'=> array(
'driver'=> array(
'zfcuser_driver'=> array(
'class'=>'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache'=>'array',
'paths'=> array(__ DIR__。
'orm_default'=> array(
'drivers'=> array(
'ZfcUser\ Entity'=>'zfcuser_driver'
)
)
)
),
);
我看到模块 zfcuserDoctrineORM 可以使用XML。
模块可以适应于注释吗?如果可以的话,我该怎么调整我的实体用户到这个模块?哪些档案应该修改?
您不需要调整使用注释映射。 本身支持混合映射(您可以选择决定使用哪些驱动程序映射哪些实体)。关于的配置,我个人没有修改它(我只做了一些覆盖关于什么ZfcUserDoctrineORM做的)。
- 删除 config / autoload / zfcuser.global.php (你不需要)
- 删除 config / autoload / zfcuserdoctrineorm.global.php
-
在定义您的用户实体的模块中,如果要覆盖ZfcUserDoctrineOrm的注释驱动程序(假设文件在 YourModule / config / module.config.php ):
//实体映射
'doctrine'=> array(
'driver'=> array(
'zfcuser_entity'=> array(
// custom path
'class'=>'Doctrine\ORM\\ \\ Mapping \Driver\AnnotationDriver',
'paths'=>数组(__ DIR__。'/../src/YourModule/Entity'),
),
'orm_default' =>数组(
'drivers'=>数组(
'YourModule\Entity'=>'zfcuser_entity',
),
),
),
),
// ZfcUser specific config
'zfcuser'=> array(
'user_entity_class'=>'YourModule\Entity\User',
'enable_default_entities'=> false,
),
这应该适用于 0.1.x 版本 ZfcUserDoctrineORM
I’m writing from Argentina, forgive my English little. I’m having some problems with modules ZfcUser and zfcuserDoctrineORM. I need to integrate them into my project. I’m working with Zend framework 2 , doctrine 2.3 and postgreSQL and this is the first time I work with these tools. For that reason, there are many things that I don’t dominate well, I have all the modules included in my /config/application.config.php and my connection is configured in my database in /config/autoload/local.php
Local.php
return array( 'doctrine' => array( 'connection' => array( 'orm_default' =>array( 'driverClass' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver', 'params' => array( 'host' => 'localhost', 'port' => '5432', 'user' => 'postgres', 'password' => 'postgres', 'dbname' => 'ministerio', ) ) ) ), );
application.config.php
return array( 'modules' => array( 'Application', 'DoctrineModule', 'DoctrineORMModule', 'Reeser', // Name of my module 'ZfcBase', 'ZfcUser', 'ZfcUserDoctrineORM', ), 'module_listener_options' =>array( 'config_glob_paths' =>array( 'config/autoload/{,*.}{global,local}.php', ), 'module_paths' =>array( './module', './vendor', ), ), );
In order to map my database I made use of annotations with doctrine and I have my own entity user generated in my module.
I added the configuration archives zfcuser.global.php and zfcuserdoctrineorm.global.php in my autoload directory but I don’t know how to configure them so that the archives recognize my entity.
Into zfcuser.global.php
'zend_db_adapter' => 'Zend\Db\Adapter\Adapter', // should this comment it? 'user_entity_class' => 'Reeser\Entity\User', 'login_redirect_route' => 'Reeser/index/index.phtml', return array( 'zfcuser' => $settings, // How I configure this code? 'service_manager' =>array( 'aliases' => array( 'zfcuser_zend_db_adapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'Zend\Db\Adapter\Adapter', ), ), );
Into zfcuserdoctrineorm.global.php
return array( 'doctrine' => array( 'driver' => array( 'zfcuser_driver' =>array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'cache' => 'array', 'paths' => array(__DIR__ .'/../src/Reeser/Entity') ), 'orm_default' =>array( 'drivers' => array( 'ZfcUser\Entity' => 'zfcuser_driver' ) ) ) ), );
I saw that module zfcuserDoctrineORM works with XML.Can the module be adapted to work with annotations? If this is possible, how do I adapt my entity user to this module? Which archives should I modify ?
You don't need to adapt ZfcUserDoctrineORM to use annotation mappings. DoctrineORMModule supports mixed mappings natively (it's your choice to decide which entities to map with which drivers). About ZfcUser's configuration, I personally didn't modify it at all (I only did some overrides on what ZfcUserDoctrineORM does).
- remove config/autoload/zfcuser.global.php (you don't need it)
- remove config/autoload/zfcuserdoctrineorm.global.php
in the module defining your user entity, use following if you want to override the annotation driver of ZfcUserDoctrineOrm (assuming the file is in YourModule/config/module.config.php):
// entity mappings 'doctrine' => array( 'driver' => array( 'zfcuser_entity' => array( // customize path 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'paths' => array(__DIR__ . '/../src/YourModule/Entity'), ), 'orm_default' => array( 'drivers' => array( 'YourModule\Entity' => 'zfcuser_entity', ), ), ), ), // ZfcUser specific config 'zfcuser' => array( 'user_entity_class' => 'YourModule\Entity\User', 'enable_default_entities' => false, ),
This should work for the 0.1.x versions of ZfcUserDoctrineORM
这篇关于如何使用注释在doctrine 2的项目中调整ZfcUser / zfcuserDoctrineORM模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!