symfony2不是有效的实体或映射的超类 [英] symfony2 is not a valid entity or mapped super class

查看:238
本文介绍了symfony2不是有效的实体或映射的超类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个symfony2应用程序,在我的本地电脑用ubuntu和工作良好,但在服务器与CentOS和Cpanel不工作,我得到这个错误:

I have a symfony2 app, in my local pc with ubuntu and works well, but in server with CentOS and Cpanel not works, I obtained this error:


类Propa\PageBundle\Entity\Page不是有效的实体或映射的
超类。

Class "Propa\PageBundle\Entity\Page" is not a valid entity or mapped super class.

CRITICAL - Doctrine\ORM\Mapping\MappingException:Class
Propa\PageBundle\Entity\Page不是有效的实体或映射的super
类。 (未捕获异常)
/home/estudi83/domains/serverprova.com.es/propa/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php
线216

CRITICAL - Doctrine\ORM\Mapping\MappingException: Class "Propa\PageBundle\Entity\Page" is not a valid entity or mapped super class. (uncaught exception) at /home/estudi83/domains/serverprova.com.es/propa/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 216

我证明:

$page=$em->getRepository('PropaPageBundle:Page')->findOneBy(array('codi'=>'0001'));

并获得此错误:未知实体命名空间别名'PropaPageBundle' code>

And obtain this error: Unknown Entity namespace alias 'PropaPageBundle'.

我证明:

 $page=$em->getRepository('Propa\PageBundle\Entity\Page')->findOneBy(array('codi'=>'0001'));

并获得相同的错误:类Propa\PageBundle\Entity\\ \\ Page不是有效的实体或映射的超类。

这是Entity:

<?php
namespace Propa\PageBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Propa\PageBundle\Util;
use Gedmo\Mapping\Annotation as Gedmo;




/**
 * @ORM\Entity(repositoryClass="Propa\PageBundle\Repository\PageRepository")
 * @Gedmo\TranslationEntity(class="Propa\PageBundle\Entity\Translation\PageTranslation")
 * @ORM\HasLifecycleCallbacks
 * @Vich\Uploadable
 */

class Page {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

我证明了:

auto_mapping: true

auto_mapping: false
mappings:
    PageBundle: ~

但总是得到相同的错误。

But always obtain the same error.

我能做什么?

更新:解决的问题是在eAccelerator与symfony2注释,我卸载eAccelerator和安装APC和工作正常!!

UPDATE: Resolved the problem was in eAccelerator with symfony2 annotations, I'm uninstalled eAccelerator and installed APC and works fine!!

推荐答案

最后,它可能是一个缓存优化器问题。如果你使用eAccelerator,那么你会有问题,可能与Doctrine。原因是eAccelerator从代码中删除注释!您可以尝试使用原则执行的APC。

Finally, it may be a cache optimizer issue. If you are using eAccelerator, then you will have problems, probably with Doctrine. The reason is eAccelerator removes annotations from the code! You can try APC which performs well with doctrine.

阅读 apc vs eaccelerator vs xcache

查看

http://you.site.name/config.php

它显示了您应用程序的工作需求。

It shows you the requirements that should be present to make your application work.

AND

请公开您的专页实体类别。

please expose your page entity class.

这个错误原因可能有很多,已在此处询问SO XXX类不是有效实体或映射超类在文件系统中移动类后

There may be many reasons for this error and your question was already asked here on SO "Class XXX is not a valid entity or mapped super class" after moving the class in the filesystem

https://github.com/symfony/symfony/issues/4554

$page=$em->getRepository('PageBundle:Page')->findOneBy(array('codi'=>'0001'));

更改为

 $page=$em->getRepository('PropaPageBundle:Page')->findOneBy(array('codi'=>'0001'));

 $page=$em->getRepository('Propa\PageBundle\Entity\Page')->findOneBy(array('codi'=>'0001'));

并查看其是否有效。

这篇关于symfony2不是有效的实体或映射的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆