问题
My knowledge of php composer is no more than basic, but... I've downloaded and installed the Zend Framework 3.0.0dev MVC skeleton app and wanted to find out if I could install the Doctrine ORM module along with it. composer require doctrine/doctrine-orm-module
complains about
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.
so I try downgrading zendframework/zend-mvc to 2.7.9 in composer.json and try again:
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].
and I suspect that the reason I can't make composer happy is that this just cannot be done -- i.e., doctrine-orm-module is not (yet) compatible with ZF3. True?
回答1:
DoctrineORMModule 1.1.0 and DoctrineModule 1.2.0 have been released. These should finally add ZF3 compatibility.
回答2:
Problem 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.
composer require doctrine/doctrine-orm-module
install on zf3-skeleton
回答3:
There is a package container-interop-doctrine available, that is compatible with the Zend Service Manger (due to the container-interop compability).
Installation and usage is pretty similar to the doctrine/doctrine-orm-module
:
composer require dasprid/container-interop-doctrine
It can be activated by by creating a new file 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/',
],
],
],
];
Once activated, you can get the EntityManger
almost the same way as with the doctrine-orm-module
:
$serviceLocator->get('doctrine.entity_manager.orm_default');
The only noticable change is, that entity_manger
instead of enititymanager
.
There's a blog-post for installation / usage too.
回答4:
You can try fanst1109/doctrine-orm-module
composer require fanst1109/doctrine-orm-module
It is a Zend Framework 3 Module that provides Doctrine ORM functionality
来源:https://stackoverflow.com/questions/38103803/is-it-possible-to-install-doctrine-orm-module-with-zf3-skeleton-app