要处理的zf2 + doctrine2和No Metadata类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了要处理的zf2 + doctrine2和No Metadata类相关的知识,希望对你有一定的参考价值。
我正在使用教程http://www.nuvolia.com/2013/03/09/zend_framework_doctrine_install/。使用Doctrine ORM的模块Application fork很好但是当我想要在另一个模块中连接时,我正在发现错误:
d:Aptana StudioProjectsapp01>vendorindoctrine-module orm:schema-tool:create
Deprecated: "SymfonyComponentConsoleHelperDialogHelper" is deprecated since
version 2.5 and will be removed in 3.0. Use "SymfonyComponentConsoleHelperQu
estionHelper" instead. in D:Aptana StudioProjectsapp01vendorsymfonyconsole
HelperDialogHelper.php on line 34
No Metadata Classes to process.
d:Aptana StudioProjectsapp01>
我从skeleton创建的应用程序,Module有这样的代码:/app01/module/MyBlog/config/module.config.php
<?php
namespace MyBlog;
return array(
'doctrine' => array(
'driver' => array(
'myblog_entity' => array(
'class' => 'DoctrineORMMappingDriverAnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/MyBlog/Entity')
),
'orm_default' => array(
'drivers' => array(
'MyBlogEntity' => 'myblog_entity'
)
)
),
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array(
'GedmoTimestampableTimestampableListener',
// 'GedmoSoftDeleteableSoftDeleteableListener',
// 'GedmoTranslatableTranslatableListener',
// 'GedmoBlameableBlameableListener',
// 'GedmoLoggableLoggableListener',
// 'GedmoSluggableSluggableListener',
// 'GedmoSortableSortableListener',
// 'GedmoTreeTreeListener',
),
),
)
)
);
/app01/module/my blog/双人床/my blog/entity/blog post.PHP
<?php
namespace MyBlogEntity;
//use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
use DoctrineORMMapping as ORM;
use GedmoMappingAnnotation as Gedmo;
class BlogPost {
/**
* @var int
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
* @Column(type="string", length=255, nullable=false)
*/
protected $title;
/**
* Get id.
*
* @return int
*/
public function getId() {
return $this -> id;
}
/**
* Set id.
*
* @param int $id
*
* @return void
*/
public function setId($id) {
$this -> id = (int)$id;
}
/**
* Get title.
*
* @return string
*/
public function getTitle() {
return $this -> title;
}
/**
* Set title.
*
* @param string $title
*
* @return void
*/
public function setTitle($title) {
$this -> title = $title;
}
}
/app01/module/my blog/module.PHP
<?php
namespace MyBlog;
class Module
{
public function getAutoloaderConfig()
{
return array(
'ZendLoaderStandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
//__NAMESPACE__ => __DIR__ . '/src/' . str_replace('\', '/' , __NAMESPACE__),
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
/app01/config/application.config.PHP
return array(
// This should be an array of module namespaces used in the application.
'modules' => array(
'Application',
'DoctrineModule',
'DoctrineORMModule',
'ZendDeveloperTools',
'MyBlog'
),
/app01/config/auto load/doctrine.local.PHP
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'DoctrineDBALDriverPDOmysqlDriver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'zf2guard',
'password' => 'zf2guard',
'dbname' => 'app01',
'driverOptions' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'),
)
)
),
),
);
我做错了什么?为什么它在应用程序模块中有效并且在其他模块中不起作用?我尝试从我的班级(doctrine 2 no metadata classes to process)中移除ORM,但没有任何改变。你有什么想法吗?
答案
您的实体没有@ORMEntity
注释。在这种情况下,类 - 元数据AnnotationDriver会跳过整个类。
/**
* @ORMEntity
* @ORMTable(name="blog_post")
*/
class BlogPost
{
// ...
}
以上是关于要处理的zf2 + doctrine2和No Metadata类的主要内容,如果未能解决你的问题,请参考以下文章
zf2 doctrine2如何在实体列中使用tinyint数据类型