简体   繁体   English

Doctrine “实体”不是有效实体或映射的超级 class

[英]Doctrine "Entity" is not a valid entity or mapped super class

In my doctrine.php I have the following configuration在我的doctrine.php我有以下配置

<?php

// See https://symfony.com/doc/current/reference/configuration/framework.html

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
    $container->extension('doctrine', [
        'dbal' => [
            'url' => '%env(DATABASE_URL)%',
        ],
        'orm' => [
            'auto_generate_proxy_classes' => true,
            'auto_mapping' => true,
            'mappings' => [
                'default' => [
                    'is_bundle' => false,
                    'type' => 'annotation',
                    'dir' => '%kernel.project_dir%/src/Entity',
                    'prefix' => 'App\Entity',
                    'alias' => 'App'
                ]
            ]
        ]
    ]);
};

And my Entity class is defined as follows而我的实体 class 定义如下

namespace App\Entity;

use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;

#[Entity(repositoryClass: EntityRepository::class)]
#[Table(name: 'entity')]
class Entity

...

I tried accessing it like by calling getRepository like this我尝试通过像这样调用getRepository来访问它

$entityRepository = $entityManager->getRepository(Entity::class);

But this fails with the is not a valid entity or mapped super class但这is not a valid entity or mapped super class

PS附言

If necessary, this is my EntityRepository.php如有必要,这是我的EntityRepository.php

<?php

namespace App\Repository;

use App\Entity\Entity;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class EntityRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Entity::class);
    }
}

I found an issue.我发现了一个问题。 I am a dummy..我是个假人。。

I had to change我不得不改变

'type' => 'annotation'

to

'type' => 'attribute'

Since I'm using php8 syntax.因为我使用的是 php8 语法。 Sorry lads!对不起小伙子们!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Doctrine不是有效实体或映射超类 - Doctrine Is not a valid entity or mapped super class Doctrine2-“类”不是有效实体或映射的超类 - Doctrine2 - “class” is not a valid entity or mapped super class 带有zend 1的理论2给出“类xxx不是有效的实体或映射的超类” - doctrine 2 with zend 1 gives 'class xxx is not a valid entity or mapped super class' 原则:类不是有效的实体或映射的超类,错误 - Doctrine: Class is not a valid entity or mapped super class, error Symfony / Doctrine:Class不是有效实体或映射超类 - Symfony/Doctrine: Class is not a valid entity or mapped super class Doctrine \\ Common \\ Collections \\ ArrayCollection类不是有效实体或映射的超类 - Class Doctrine\Common\Collections\ArrayCollection is not a valid entity or mapped super class Symfony主义ORM不是有效的实体或映射的超类 - Symfony Doctrine ORM not a valid entity or mapped super class Not a valid entity or mapped super class 来自 Doctrine 的错误 - Not a valid entity or mapped super class error from Doctrine 消息为“ Class Entity \\ Ssclass”的未捕获异常“ Doctrine \\ ORM \\ Mapping \\ MappingException”不是有效实体或映射的超类 - Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class Entity\Ssclass is not a valid entity or mapped super class 具有教义2的Codeigniter 3-Doctrine \\ ORM \\ Mapping \\ MappingException类不是有效实体或映射的超类 - Codeigniter 3 with Doctrine 2 - Doctrine\ORM\Mapping\MappingException Class is not a valid entity or mapped super class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM