Symfony 2 FOSUserBundle问题

时间:2015-04-22 08:28:16

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

我在symfony 2工作,我尝试使用FOSUserBundle,但我无法解决此问题:help plz

[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');
    }
}

2 个答案:

答案 0 :(得分:0)

似乎你忘了添加new FOS\UserBundle\FOSUserBundle(),app / AppKernel.php registerBundles方法。

答案 1 :(得分:0)

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