通过AppKernel.php检测捆绑包symfony 2.5.6

时间:2015-05-28 13:58:20

标签: php symfony

我遇到了AppKernel和捆绑检测器的问题。

我在2.5.6工作

确实,我有这个错误: Bundle" mainBundle"不存在或未启用。也许您忘了将它添加到AppKernel.php文件的registerBundles()方法中?

但这是我的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 theia\mainBundle\theiamainBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            //$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            $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');
    }
}

当我尝试将所谓的bundle的routing.yml与app / config / routing.yml或routing_dev.yml链接时,我遇到了这个问题。

要做到这一点,我在app /.../ routing.yml

中添加它
t:
    resource: "@theiamainBundle/Resources/config/routing.yml"
    prefix:   /

错误追踪:

  第2359行的kernel.root_dir / bootstrap.php.cache中的

- public   function getBundle($ name,$ first = true){if   (!isset($ this-&gt; bundleMap [$ name])){throw new   \ InvalidArgumentException(sprintf(&#39; Bundle&#34;%s&#34;不存在或者它是   没有启用。也许你忘了把它添加到registerBundles()中   %s.php文件的方法?&#39;,$ name,get_class($ this))); } 如果是真的   === $ first){return $ this-&gt; bundleMap [$ name] [0]; at kernel - &gt; getBundle(&#39; mainBundle&#39;,false)在kernel.root_dir / cache / dev / classes.php中   第2332行+在ControllerNameParser - &gt;解析   (&#39; mainBundle:security:login&#39;)in   kernel.root_dir / cache / dev / classes.php在第2384行+ at   ControllerResolver - &gt; createController(&#39; mainBundle:security:login&#39;)   在kernel.root_dir / cache / dev / classes.php第2047行+ at   ControllerResolver - &gt; getController(object(Request))in   /opt/lampp/htdocs/my_projects/Symphony_projects/test/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php   在第46行+在TraceableControllerResolver - &gt; getController   (对象(请求))在第2969行的kernel.root_dir / bootstrap.php.cache中   +在HttpKernel - &gt; handleRaw(object(Request),&#39; 1&#39;)在kernel.root_dir / bootstrap.php.cache第2938行+在HttpKernel    - &gt;句柄(对象(请求),&#39; 1&#39;,true)在kernel.root_dir / bootstrap.php.cache第3087行+ at   ContainerAwareHttpKernel - &gt; handle(object(Request),&#39; 1&#39;,true)in   kernel.root_dir / bootstrap.php.cache在第2337行+内核    - &gt; handle(object(Request))inopt/lampp/htdocs/my_projects/Symphony_projects/test/web/app_dev.php   在第28行

这是日志跟踪

  

信息 - 匹配的路线&#34; login_route&#34; (参数:&#34; _controller&#34;:&#34; mainBundle:security:login&#34;,&#34; _route&#34;:&#34; login_route&#34;)   INFO - 使用匿名令牌填充SecurityContext   DEBUG - 通知事件&#34; kernel.request&#34; to listener&#34; Symfony \ Component \ HttpKernel \ EventListener \ ErrorsLoggerListener :: injectLogger&#34;。   DEBUG - 通知事件&#34; kernel.request&#34; to listener&#34; Symfony \ Component \ HttpKernel \ EventListener \ ErrorsLoggerListener :: injectLogger&#34;。   DEBUG - 通知事件&#34; kernel.request&#34; to listener&#34; Symfony \ Component \ HttpKernel \ EventListener \ ErrorsLoggerListener :: injectLogger&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;监听器&#34; Symfony \ Component \ HttpKernel \ EventListener \ DebugHandlersListener :: configure&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;侦听器&#34; Symfony \ Component \ HttpKernel \ EventListener \ ProfilerListener :: onKernelRequest&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;侦听器&#34; Symfony \ Bundle \ FrameworkBundle \ EventListener \ SessionListener :: onKernelRequest&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;监听器&#34; Symfony \ Component \ HttpKernel \ EventListener \ FragmentListener :: onKernelRequest&#34;。   DEBUG - 通知事件&#34; kernel.request&#34; to listener&#34; Symfony \ Component \ HttpKernel \ EventListener \ RouterListener :: onKernelRequest&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;监听器&#34; Symfony \ Component \ HttpKernel \ EventListener \ LocaleListener :: onKernelRequest&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;监听器&#34; Symfony \ Component \ Security \ Http \ Firewall :: onKernelRequest&#34;。   DEBUG - 通知事件&#34; kernel.request&#34;监听器&#34; Symfony \ Bundle \ AsseticBundle \ EventListener \ RequestListener :: onKernelReque   ST&#34;

     

CRITICAL - 未捕获的PHP异常InvalidArgumentException:&#34; Bundle   &#34; mainBundle&#34;不存在或未启用。也许你忘记了   将它添加到AppKernel.php文件的registerBundles()方法中?&#34;在   /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache   第2359行

     

DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ ErrorsLoggerListener :: injectLogger&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ ErrorsLoggerListener :: injectLogger&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ ErrorsLoggerListener :: injectLogger&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ DebugHandlersListener ::配置&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ ProfilerListener :: onKernelRequest&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\捆绑\ FrameworkBundle \事件监听\ SessionListener :: onKernelRequest&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ FragmentListener :: onKernelRequest&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ RouterListener :: onKernelRequest&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\ HttpKernel \事件监听\ LocaleListener :: onKernelRequest&#34 ;.   DEBUG - 通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\元器件\安全\ HTTP \防火墙:: onKernelRequest&#34 ;.调试 -   通知事件&#34; kernel.request&#34;听众   &#34; Symfony的\捆绑\ AsseticBundle \事件监听\ RequestListener :: onKernelRequest&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Symfony的\捆绑\ FrameworkBundle \ DataCollector \ RouterDataCollector :: onKernelController&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Symfony的\元器件\ HttpKernel \ DataCollector \ RequestDataCollector :: onKernelController&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Sensio公司\捆绑\ FrameworkExtraBundle \事件监听\ ControllerListener :: onKernelController&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Sensio公司\捆绑\ FrameworkExtraBundle \事件监听\ ParamConverterListener :: onKernelController&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Sensio公司\捆绑\ FrameworkExtraBundle \事件监听\ HttpCacheListener :: onKernelController&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Sensio公司\捆绑\ FrameworkExtraBundle \事件监听\ SecurityListener :: onKernelController&#34 ;.   DEBUG - 通知事件&#34; kernel.controller&#34;听众   &#34; Sensio公司\捆绑\ FrameworkExtraBundle \事件监听\ TemplateListener :: onKernelController&#34;

以下是Stack Trace:

  

[1] InvalidArgumentException:Bundle&#34; mainBundle&#34;不存在或未启用。也许你忘了在AppKernel.php文件的registerBundles()方法中添加它?       在n / a           在/opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache第2359行

at Symfony\Component\HttpKernel\Kernel->getBundle('mainBundle', false)
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/cache/dev/classes.php line 2332

at Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser->parse('mainBundle:security:login')
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/cache/dev/classes.php line 2384

at Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver->createController('mainBundle:security:login')
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/cache/dev/classes.php line 2047

at Symfony\Component\HttpKernel\Controller\ControllerResolver->getController(object(Request))
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php line 46

at Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController(object(Request))
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2969

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2938

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 3087

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2337

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/web/app_dev.php line 28

你知道它可能来自哪里吗?你需要更多的文件来帮助我吗?

1 个答案:

答案 0 :(得分:0)

在指定控制器时,您的路径似乎引用了“mainBundle”,该控制器应为“theiamainBundle”:

Matched route "login_route" (parameters: "_controller": "mainBundle:security:login", "_route": "login_route")