zf2 + doctrine2 和没有要处理的元数据 类
zf2 + doctrine2 and No Metadata Classes to process
我正在使用教程 http://www.nuvolia.com/2013/03/09/zend_framework_doctrine_install/。模块 Application fork 与 Doctrine ORM 很好,但是当我试图连接到另一个模块时,我收到错误:
d:\Aptana Studio\Projects\app01>vendor\bin\doctrine-module orm:schema-tool:create
Deprecated: "Symfony\Component\Console\Helper\DialogHelper" is deprecated since
version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Qu
estionHelper" instead. in D:\Aptana Studio\Projects\app01\vendor\symfony\console
\Helper\DialogHelper.php on line 34
No Metadata Classes to process.
d:\Aptana Studio\Projects\app01>
我从骨架创建的应用程序,模块有这样的代码:
/app01/module/MyBlog/config/module.config.php
<?php
namespace MyBlog;
return array(
'doctrine' => array(
'driver' => array(
'myblog_entity' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/MyBlog/Entity')
),
'orm_default' => array(
'drivers' => array(
'MyBlog\Entity' => 'myblog_entity'
)
)
),
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array(
'Gedmo\Timestampable\TimestampableListener',
// 'Gedmo\SoftDeleteable\SoftDeleteableListener',
// 'Gedmo\Translatable\TranslatableListener',
// 'Gedmo\Blameable\BlameableListener',
// 'Gedmo\Loggable\LoggableListener',
// 'Gedmo\Sluggable\SluggableListener',
// 'Gedmo\Sortable\SortableListener',
// 'Gedmo\Tree\TreeListener',
),
),
)
)
);
/app01/module/MyBlog/src/MyBlog/Entity/BlogPost.php
<?php
namespace MyBlog\Entity;
//use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
class BlogPost {
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(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/MyBlog/Module.php
<?php
namespace MyBlog;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => 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/autoload/doctrine.local.php
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'zf2guard',
'password' => 'zf2guard',
'dbname' => 'app01',
'driverOptions' => array(
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'),
)
)
),
),
);
我做错了什么?为什么它在应用程序模块中工作,而在其他模块中不工作?
我尝试从我的 Class (doctrine 2 no metadata classes to process) 中删除 ORM,但没有任何变化。
你有什么想法吗?
您的实体没有 @ORM\Entity
注释。在那种情况下,整个 class 被 class-metadata AnnotationDriver 跳过。
/**
* @ORM\Entity
* @ORM\Table(name="blog_post")
*/
class BlogPost
{
// ...
}
我正在使用教程 http://www.nuvolia.com/2013/03/09/zend_framework_doctrine_install/。模块 Application fork 与 Doctrine ORM 很好,但是当我试图连接到另一个模块时,我收到错误:
d:\Aptana Studio\Projects\app01>vendor\bin\doctrine-module orm:schema-tool:create
Deprecated: "Symfony\Component\Console\Helper\DialogHelper" is deprecated since
version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Qu
estionHelper" instead. in D:\Aptana Studio\Projects\app01\vendor\symfony\console
\Helper\DialogHelper.php on line 34
No Metadata Classes to process.
d:\Aptana Studio\Projects\app01>
我从骨架创建的应用程序,模块有这样的代码: /app01/module/MyBlog/config/module.config.php
<?php
namespace MyBlog;
return array(
'doctrine' => array(
'driver' => array(
'myblog_entity' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/MyBlog/Entity')
),
'orm_default' => array(
'drivers' => array(
'MyBlog\Entity' => 'myblog_entity'
)
)
),
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array(
'Gedmo\Timestampable\TimestampableListener',
// 'Gedmo\SoftDeleteable\SoftDeleteableListener',
// 'Gedmo\Translatable\TranslatableListener',
// 'Gedmo\Blameable\BlameableListener',
// 'Gedmo\Loggable\LoggableListener',
// 'Gedmo\Sluggable\SluggableListener',
// 'Gedmo\Sortable\SortableListener',
// 'Gedmo\Tree\TreeListener',
),
),
)
)
);
/app01/module/MyBlog/src/MyBlog/Entity/BlogPost.php
<?php
namespace MyBlog\Entity;
//use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
class BlogPost {
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(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/MyBlog/Module.php
<?php
namespace MyBlog;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => 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/autoload/doctrine.local.php
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'zf2guard',
'password' => 'zf2guard',
'dbname' => 'app01',
'driverOptions' => array(
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'),
)
)
),
),
);
我做错了什么?为什么它在应用程序模块中工作,而在其他模块中不工作? 我尝试从我的 Class (doctrine 2 no metadata classes to process) 中删除 ORM,但没有任何变化。 你有什么想法吗?
您的实体没有 @ORM\Entity
注释。在那种情况下,整个 class 被 class-metadata AnnotationDriver 跳过。
/**
* @ORM\Entity
* @ORM\Table(name="blog_post")
*/
class BlogPost
{
// ...
}