Answer the question
In order to leave comments, you need to log in
How to connect doctrine to zend expressive?
I'm trying to fasten the doctrine to Zend. Here are
doctrine.global.php configs
return [
'doctrine' => [
'driver' => [
'orm_default' => [
'class' => \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class,
'drivers' => [],
],
],
],
];
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'params' => [
'url' => 'mysql://project:[email protected]/project',
],
],
],
],
];
return [
'dependencies' => [
'abstract_factories' => [
\Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::class
],
];
[email protected]:/application# php /application/vendor/doctrine/orm/bin/doctrine
PHP Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to create service "Doctrine\DBAL\Connection"; unable to resolve parameter "driver" using type hint "Doctrine\DBAL\Driver" in /application/vendor/zendframework/zend-servicemanager/src/AbstractFactory/ReflectionBasedAbstractFactory.php:226
Answer the question
In order to leave comments, you need to log in
everything turned out to be simple, you need to connect the ContainerInteropDoctrine factory
https://github.com/DASPRiD/container-interop-doctrine
in dependencies.global.php
'factories' => [
\Doctrine\ORM\EntityManager::class => \ContainerInteropDoctrine\EntityManagerFactory::class,
],
Something like this: https://github.com/doctrine/DoctrineORMModule#conn...
<?php
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'driverClass' => \Doctrine\DBAL\Driver\PDOMySql\Driver::class,
'params' => [
'host' => 'localhost',
'port' => '3306',
'user' => 'username',
'password' => 'password',
'dbname' => 'database',
'driverOptions' => [
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
],
],
],
],
],
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question