【问题标题】:Symfony 2 FOSUserBundle problemsSymfony 2 FOSUserBundle 问题
【发布时间】:2015-04-22 08:28:15
【问题描述】:

我在 symfony 2 中工作,我正在尝试使用 FOSUserBundle 但我无法解决这个问题:请帮助

[LogicException]                                                             
  Bundle "BlogUserBundle" extends bundle "FOSUserBundle", 
  which is not registered.  




<?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 AppBundle\AppBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new Blog\UserBundle\BlogUserBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $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(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}

【问题讨论】:

  • 很可能你还没有在AppKernel.php 注册你的包,你能再检查一次吗?
  • 我已经做了,这是我的内核
  • 您能否编辑您的问题,添加您的 AppKernel::registerBundles 方法的代码?

标签: symfony symfony-forms symfony-2.1 symfony-2.3


【解决方案1】:

好像忘记添加new FOS\UserBundle\FOSUserBundle(), app/AppKernel.php registerBundles 方法。

【讨论】:

  • 我也这样做了,新的 Blog\UserBundle\BlogUserBundle(),因为我的新包在 src->Blog->UserBundle
【解决方案2】:

在 app/AppKernel.php 中的 new AppBundle\AppBundle(), 行之后添加 new FOS\UserBundle\FOSUserBundle(),

【讨论】:

  • 我得到了这个 ClassNotFoundException: Attempted to load class "FOSUserBundle" from namespace "FOS\UserBundle" in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\nomProjet\ app\AppKernel.php 第 20 行。你需要从另一个命名空间“使用”它吗?
  • 捆绑包在您的供应商中?
  • 是的,我的供应商在这个结构中:vendor->friendsofsymfony->user-bundle
  • 没有。你能正确粘贴你的 AppKernel.php 文件更新了 FOSUserBundle 注册吗?
猜你喜欢
  • 2018-02-26
  • 2023-04-07
  • 2018-09-29
  • 1970-01-01
  • 2013-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-30
相关资源
最近更新 更多