2
我想整合学说2与zf2。我按照这个教程:http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/学说2和Zf2的整合
但我有一些问题与教条cli。
当我输入“project \ vendor \ doctrine \ doctrine-module \ bin \ doctrine-module orm:generate-proxies”时,它给了我这个消息:'没有要处理的元数据类。
这是我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'
)
)
)
)
);
这是\用户\ SRC \实体\ 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;
}
如果我从注释删除ORM \它给我的信息'用户\实体\用户类中的注释“@Entity”永远不会被导入。你可能忘记为这个注释添加一个“使用”语句吗?'
做到了,现在它给了我这个错误:Zend \ ServiceManager \ Exception \ ServiceNotCreatedException:'创建doctrine.entitymanager.orm时引发了一个异常default没有实例在第733行的项目\ vendor \ zendframework \ zendframework \ library \ Zend \ ServiceManager \ ServiceManager.php中返回 –