是否可以使用 ZF3 骨架应用程序安装 doctrine orm 模块?

is it possible to install doctrine orm module with ZF3 skeleton app?

我对 php composer 的了解不过是基本知识,但是...我已经下载并安装了 Zend Framework 3.0.0dev MVC skeleton app and wanted to find out if I could install the Doctrine ORM modulecomposer require doctrine/doctrine-orm-module 抱怨

Problem 1
- Installation request for doctrine/doctrine-orm-module ^0.10.0 -> satisfiable by doctrine/doctrine-orm-module[0.10.0].
- doctrine/doctrine-orm-module 0.10.0 requires zendframework/zend-mvc ~2.3 -> satisfiable by zendframework/zend-mvc[2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3.7, 2.3.8, 2.3.9, 2.4.0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0rc5, 2.4.0rc6, 2.4.0rc7, 2.4.1, 2.4.10, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8, 2.4.9, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.7.0, 2.7.1, 2.7.10, 2.7.2, 2.7.3, 2.7.4, 2.7.5, 2.7.6, 2.7.7, 2.7.8, 2.7.9] but these conflict with your requirements or minimum-stability.

所以我尝试在 composer.json 中将 zendframework/zend-mvc 降级到 2.7.9,然后重试:

 Problem 1
- The requested package zendframework/zend-mvc (installed at 3.0.1, required as 2.7.9) is satisfiable by zendframework/zend-mvc[3.0.1] but these conflict with your requirements or minimum-stability.
Problem 2
- zendframework/zend-mvc 2.7.9 conflicts with zendframework/zend-router[3.0.2].
- zendframework/zend-mvc 2.7.9 conflicts with zendframework/zend-router[3.0.2].
- Installation request for zendframework/zend-mvc 2.7.9 -> satisfiable by zendframework/zend-mvc[2.7.9].
- Installation request for zendframework/zend-router (installed at 3.0.2) -> satisfiable by zendframework/zend-router[3.0.2].

而且我怀疑我不能让 composer 高兴的原因是这根本无法完成——即 doctrine-orm-module 不(还)与 ZF3 兼容。真的?

DoctrineORMModule 1.1.0 and DoctrineModule 1.2.0 已发布。这些应该最终添加 ZF3 兼容性。

问题 1

- Installation request for doctrine/doctrine-orm-module ^0.11.0 -> satisfiable by doctrine/doctrine-orm-module[0.11.0].
- doctrine/doctrine-orm-module 0.11.0 requires zendframework/zend-mvc ^2.5.2 -> satisfiable by zendframework/zend-mvc[2.5.2, 2.5.3, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.7.0, 2.7.1, 2.7.10, 2.7.2, 2.7.3, 2.7.4, 2.7.5, 2.7.6, 2.7.7, 2.7.8, 2.7.9] but these conflict with your requirements or minimum-stability.

作曲家要求 doctrine/doctrine-orm-module

在 zf3-skeleton 上安装

有一个包 container-interop-doctrine 可用,它与 Zend Service Manger 兼容(由于容器互操作性)。

安装和使用与 doctrine/doctrine-orm-module:

非常相似
composer require dasprid/container-interop-doctrine

可以通过新建文件激活data/config/autoload/doctrine.global.php:

<?php

use ContainerInteropDoctrine\EntityManagerFactory;

return [
    'dependencies' => [
        'factories' => [
            'doctrine.entity_manager.orm_default' => EntityManagerFactory::class,
        ],
    ],

    /**
     * For full configuration options, see
     * https://github.com/DASPRiD/container-interop-doctrine/blob/master/example/full-config.php
     */
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'params' => [
                    'url' => 'mysql://user:password@localhost/database',
                ],
            ],
        ],
        'driver' => [
            'orm_default' => [
                'class' => \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class,
                'drivers' => [
                    'App\Entity' => 'my_entity',
                ],
            ],
            'my_entity' => [
                'class' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class,
                'cache' => 'array',
                'paths' => 'src/App/Entity/',
            ],
        ],
    ],
];

激活后,您可以获得 EntityManger 几乎与 doctrine-orm-module 相同的方式:

$serviceLocator->get('doctrine.entity_manager.orm_default');

唯一值得注意的变化是 entity_manger 而不是 enititymanager

还有一个 blog-post 用于安装/使用。

你可以试试fanst1109/doctrine-orm-module

composer require fanst1109/doctrine-orm-module

它是一个提供 Doctrine ORM 功能的 Zend Framework 3 模块