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

查看:17
本文介绍了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:

类PropaPageBundleEntityPage"不是有效实体或映射超级类.

Class "PropaPageBundleEntityPage" is not a valid entity or mapped super class.

CRITICAL - DoctrineORMMappingMappingException: 类PropaPageBundleEntityPage"不是有效的实体或映射的超班级.(未捕获的异常)在/home/estudi83/domains/serverprova.com.es/propa/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php第 216 行

CRITICAL - DoctrineORMMappingMappingException: Class "PropaPageBundleEntityPage" 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'));

并得到这个错误:Unknown Entity namespace alias 'PropaPageBundle'.

我证明:

 $page=$em->getRepository('PropaPageBundleEntityPage')->findOneBy(array('codi'=>'0001'));

并获得相同的错误:Class "PropaPageBundleEntityPage" 不是有效的实体或映射的超类.

这是实体:

<?php
namespace PropaPageBundleEntity;

use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;
use DoctrineCommonCollectionsArrayCollection;
use VichUploaderBundleMappingAnnotation as Vich;
use PropaPageBundleUtil;
use GedmoMappingAnnotation as Gedmo;




/**
 * @ORMEntity(repositoryClass="PropaPageBundleRepositoryPageRepository")
 * @GedmoTranslationEntity(class="PropaPageBundleEntityTranslationPageTranslation")
 * @ORMHasLifecycleCallbacks
 * @VichUploadable
 */

class Page {

    /**
     * @ORMId
     * @ORMColumn(type="integer")
     * @ORMGeneratedValue
     */
    protected $id;

我已经证明了:

auto_mapping: true

auto_mapping: false
mappings:
    PageBundle: ~

但总是得到同样的错误.

But always obtain the same error.

我能做什么?

更新:使用 symfony2 注释解决了 eAccelerator 中的问题,我卸载了 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.

请公开您的页面实体类.

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('PropaPageBundleEntityPage')->findOneBy(array('codi'=>'0001'));

看看它是否有效.

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

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