Detection of a bundle by AppKernel.php symfony 2.5.6

i am having an issue with AppKernel and the bundle detector.

I am working in 2.5.6

Indeed, i have this error: Bundle "mainBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?

But here is my AppKernel.php:

<?php

use SymfonyComponentHttpKernelKernel;
use SymfonyComponentConfigLoaderLoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new SymfonyBundleFrameworkBundleFrameworkBundle(),
            new SymfonyBundleSecurityBundleSecurityBundle(),
            new SymfonyBundleTwigBundleTwigBundle(),
            new SymfonyBundleMonologBundleMonologBundle(),
            new SymfonyBundleSwiftmailerBundleSwiftmailerBundle(),
            new SymfonyBundleAsseticBundleAsseticBundle(),
            new DoctrineBundleDoctrineBundleDoctrineBundle(),
            new SensioBundleFrameworkExtraBundleSensioFrameworkExtraBundle(),
            new theiamainBundletheiamainBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            //$bundles[] = new AcmeDemoBundleAcmeDemoBundle();
            $bundles[] = new SymfonyBundleWebProfilerBundleWebProfilerBundle();
            $bundles[] = new SensioBundleDistributionBundleSensioDistributionBundle();
            $bundles[] = new SensioBundleGeneratorBundleSensioGeneratorBundle();
        }

        return $bundles;
    }

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

I am having this issue when i try to link the routing.yml of the so called bundle with the app/config/routing.yml or routing_dev.yml.

To do this i add this in the app/.../routing.yml

t:
    resource: "@theiamainBundle/Resources/config/routing.yml"
    prefix:   /

Error Trace:

in kernel.root_dir/bootstrap.php.cache at line 2359 - public function getBundle($name, $first = true) { if (!isset($this->bundleMap[$name])) { throw new InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, get_class($this))); } if (true === $first) { return $this->bundleMap[$name][0]; at Kernel ->getBundle ('mainBundle', false) in kernel.root_dir/cache/dev/classes.php at line 2332 + at ControllerNameParser ->parse ('mainBundle:security:login') in kernel.root_dir/cache/dev/classes.php at line 2384 + at ControllerResolver ->createController ('mainBundle:security:login') in kernel.root_dir/cache/dev/classes.php at line 2047 + at ControllerResolver ->getController (object(Request)) in /opt/lampp/htdocs/my_projects/Symphony_projects/test/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php at line 46 + at TraceableControllerResolver ->getController (object(Request)) in kernel.root_dir/bootstrap.php.cache at line 2969 + at HttpKernel ->handleRaw (object(Request), '1') in kernel.root_dir/bootstrap.php.cache at line 2938 + at HttpKernel ->handle (object(Request), '1', true) in kernel.root_dir/bootstrap.php.cache at line 3087 + at ContainerAwareHttpKernel ->handle (object(Request), '1', true) in kernel.root_dir/bootstrap.php.cach e at line 2337 + at Kernel ->handle (object(Request)) in /opt/lampp/htdocs/my_projects/Symphony_projects/test/web/app_dev.php at line 28

here are the Logs trace

INFO - Matched route "login_route" (parameters: "_controller": "mainBundle:security:login", "_route": "login_route") INFO - Populated SecurityContext with an anonymous Token DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerDebugHandlersListener::configure". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerProfilerListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyBundleFrameworkBundleEventListenerSessionListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerFragmentListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerRouterListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerLocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentSecurityHttpFirewall::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyBundleAsseticBundleEventListenerRequestListener::onKernelReque st".

CRITICAL - Uncaught PHP Exception InvalidArgumentException: "Bundle "mainBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?" at /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2359

DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerDebugHandlersListener::configure". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerProfilerListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyBundleFrameworkBundleEventListenerSessionListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerFragmentListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerRouterListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerLocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyComponentSecurityHttpFirewall::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "SymfonyBundleAsseticBundleEventListenerRequestListener::onKernelRequest". DEBUG - Notified event "kernel.controller" to listener "SymfonyBundleFrameworkBundleDataCollectorRouterDataCollector::onKernelController". DEBUG - Notified event "kernel.controller" to listener "SymfonyComponentHttpKernelDataCollectorRequestDataCollector::onKernelController". DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerControllerListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerParamConverterListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerHttpCacheListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerSecurityListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerTemplateListener::onKernelController".

Here are the Stack Trace:

[1] InvalidArgumentException: Bundle "mainBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? at n/a in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2359

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

at SymfonyBundleFrameworkBundleControllerControllerNameParser->parse('mainBundle:security:login')
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/cache/dev/classes.php line 2384

at SymfonyBundleFrameworkBundleControllerControllerResolver->createController('mainBundle:security:login')
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/cache/dev/classes.php line 2047

at SymfonyComponentHttpKernelControllerControllerResolver->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 SymfonyComponentHttpKernelControllerTraceableControllerResolver->getController(object(Request))
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2969

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

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

at SymfonyComponentHttpKernelDependencyInjectionContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/app/bootstrap.php.cache line 2337

at SymfonyComponentHttpKernelKernel->handle(object(Request))
    in /opt/lampp/htdocs/my_projects/Symphony_projects/test/web/app_dev.php line 28

Do you know were it could come from? Do you need any more files in order to help me?


在指定控制器时,您的路由似乎具有对“mainBundle”的引用,该控制器应该是“theiamainBundle”:

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

链接地址: http://www.djcxy.com/p/54000.html

上一篇: Symfony2 TranslatorListener本地文化问题

下一篇: 通过AppKernel.php检测一个bundle symfony 2.5.6