noria / doctrine-orm-module
此包已被废弃,不再维护。没有建议的替代包。
提供Doctrine ORM功能的Zend Framework模块
1.1.2
2017-08-02 10:48 UTC
Requires
- php: ^5.6 || ^7.0
- doctrine/dbal: >=2.4,<2.7
- doctrine/orm: 2.5.5
- noria/doctrine-module: ^1.2.1
- symfony/console: ^2.3 || ^3.0
- zendframework/zend-servicemanager: ^2.7.6 || ^3.1
- zendframework/zend-stdlib: ^2.7.7 || ^3.0.1
Requires (Dev)
- doctrine/data-fixtures: ^1.2.1
- doctrine/migrations: ^1.4.1
- phpunit/phpunit: ^5.6.0
- squizlabs/php_codesniffer: ^2.6.2
- zendframework/zend-console: ^2.6
- zendframework/zend-developer-tools: ^1.1
- zendframework/zend-i18n: ^2.7.3
- zendframework/zend-log: ^2.9
- zendframework/zend-modulemanager: ^2.7.2
- zendframework/zend-serializer: ^2.8
Suggests
- doctrine/migrations: doctrine migrations if you want to keep your schema definitions versioned
- zendframework/zend-developer-tools: zend-developer-tools if you want to profile operations executed by the ORM during development
- zendframework/zend-form: if you want to use form elements backed by Doctrine
This package is auto-updated.
Last update: 2017-12-07 19:51:37 UTC
README
DoctrineORMModule可以快速轻松地将Doctrine 2 ORM与Zend Framework 2集成。
- 支持Doctrine 2 ORM
- 多个ORM实体管理器
- 多个DBAL连接
- 在DBAL连接中重用现有的PDO连接
安装
此模块的安装使用composer。有关composer文档,请参阅 getcomposer.org。
php composer.phar require doctrine/doctrine-orm-module
然后,将DoctrineModule
和DoctrineORMModule
添加到您的config/application.config.php
中,并创建目录data/DoctrineORMModule/Proxy
,确保您的应用程序有写入权限。
不使用composer的安装不受官方支持,需要您手动安装composer.json
中列出的所有依赖项。
实体设置
要将您的实体注册到ORM中,请为每个实体命名空间将以下元数据驱动配置添加到您的模块(合并)配置中
<?php
return array(
'doctrine' => array(
'driver' => array(
// defines an annotation driver with two paths, and names it `my_annotation_driver`
'my_annotation_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(
'path/to/my/entities',
'another/path'
),
),
// default metadata driver, aggregates all other drivers into a single one.
// Override `orm_default` only if you know what you're doing
'orm_default' => array(
'drivers' => array(
// register `my_annotation_driver` for any entity under namespace `My\Namespace`
'My\Namespace' => 'my_annotation_driver'
)
)
)
)
);
连接设置
连接参数可以在应用程序配置中定义
<?php
return array(
'doctrine' => array(
'connection' => array(
// default connection name
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'username',
'password' => 'password',
'dbname' => 'database',
)
)
)
),
);
完整的配置选项
可以在每个模块的选项类中直接找到完整的配置选项列表。
您可以在以下链接中找到有关模块功能的文档
注册的服务名称
doctrine.connection.orm_default
: 一个Doctrine\DBAL\Connection
实例doctrine.configuration.orm_default
: 一个Doctrine\ORM\Configuration
实例doctrine.driver.orm_default
: 默认映射驱动程序实例doctrine.entitymanager.orm_default
:Doctrine\ORM\EntityManager
实例Doctrine\ORM\EntityManager
:doctrine.entitymanager.orm_default
的别名doctrine.eventmanager.orm_default
:Doctrine\Common\EventManager
实例
命令行
按以下方式访问Doctrine命令行
./vendor/bin/doctrine-module
服务定位器
要访问实体管理器,请使用主服务定位器
// for example, in a controller:
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');