添加新捆绑包后缺少Symfony AppBundle映射

时间:2017-08-27 15:34:10

标签: symfony doctrine-orm

我试图在Symfony 2.7项目中使用新的实体管理器, 我创建了一个新的bundle,并添加了一个新的数据库和实体管理器。

但由于某些原因,AppBundle默认的Symfony包的配置似乎不正确。

我尝试了StackOverflow中提供的许多解决方案,但没有一个可行: 这是我的错误:

  [Doctrine\ORM\ORMException]                  
  Unknown Entity namespace alias 'AppBundle'.  

这是我的配置

orm:
    default_entity_manager: default
    auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        default:
            connection: default
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping : true
            mappings:
                AppBundle:
                    type: xml
                    dir: 'Resources/config/doctrine'
                FOSUserBundle:
                    type: xml
                    dir: 'Resources/config/doctrine-mapping'

        mailfun:
            connection: mailfun
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                MailFunBundle:
                    type: xml
                    dir: 'Resources/config/doctrine'

我尝试过但没有奏效的解决方案是:

https://stackoverflow.com/a/12616261/1765681

https://stackoverflow.com/a/29774930/1765681

https://stackoverflow.com/a/41136079/1765681

Symfony doctrine auto_mapping Unrecognized

https://stackoverflow.com/a/42949150/1765681

编辑:添加了AppKernel.php

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new JMS\SerializerBundle\JMSSerializerBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
            new Liuggio\ExcelBundle\LiuggioExcelBundle(),
            new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
            new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
            new cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle(),
            new FelDev\MailFunBundle\MailFunBundle(),
            new AppBundle\AppBundle(),

        );

        if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}

0 个答案:

没有答案