Je souhaite intégrer doctrine 2 avec zf2. Je suis ce tutoriel: http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/Intégration de Doctrine 2 et Zf2
Mais j'ai quelques problèmes avec la doctrine cli. Quand je tape «project \ vendor \ doctrine \ doctrine-module \ bin \ doctrine-module orm: generate-proxies», il me donne ce message: 'Aucune classe de métadonnées à traiter'.
Ceci est mon fichier module.config.php:
return array(
'controllers' => array(
'invokables' => array(
'User\Controller\User' => 'User\Controller\UserController',
),
),
'view_manager' => array(
'template_path_stack' => array(
'user' => __DIR__ . '/../view',
),
),
'router' => array(
'routes' => array(
'user' => array(
'type' => 'segment',
'options' => array(
'route' => '/user[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'User\Controller\User',
'action' => 'userList',
),
),
),
),
),
// Doctrine config
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
)
)
)
)
);
Et c'est le \ User \ src \ entité \ users.php
namespace User\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
/**
* @ORM\Entity
* @ORM\Table(name="user")
* @property string $username
* @property int $id
*/
class User
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @var int
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $username;
}
Si je supprime le ORM \ de annotations il me donne le message 'L'annotation "@Entity" dans la classe User \ Entity \ User n'a jamais été importé. Avez-vous oublié d'ajouter une instruction "use" pour cette annotation? '
Fait cela, et maintenant il me donne cette erreur: Zend \ ServiceManager \ Exception \ ServiceNotCreatedException: 'Une exception a été soulevée lors de la création de doctrine.entitymanager.orm par défaut aucune instance renvoyée dans le projet \ fournisseur \ zendframework \ zendframework \ bibliothèque \ Zend \ ServiceManager \ ServiceManager.php sur la ligne 733 ' –