Symfony2 package not registered

I created a new package with app / console. Trying to get a simple hello printed, so I can move on. I automatically loaded the namespace, registered the package, created the page, but Symfony detected an exception:

Bundle "PageBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your AppKernel.php file?

But I already did it.

The log displays:

[2011-06-08 23:41:56] request.CRITICAL: InvalidArgumentException: Bundle "PageBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your AppKernel.php file? (uncaught exception) at /Applications/MAMP/htdocs/Symfony/app/bootstrap.php.cache line 634 

I also cleaned the cached dev folder. Can someone help me figure out what happened. I have done this before, this is the first time I have had this problem. Something related to bootstrap.php.cache

Thank! Appreciate all the help.

CODE:

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\DoctrineBundle\DoctrineBundle(),
        new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
    );

    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        $bundles[] = new Webmuch\PageBundle\WebmuchPageBundle();
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
        $bundles[] = new Symfony\Bundle\WebConfiguratorBundle\SymfonyWebConfiguratorBundle();
    }

    return $bundles;
}

The packet is also displayed as an active bundle in the profiler.

+5
source share
2 answers

( 634 Kernel::getBundles(), , ), script, : bin\build_bootstrap.php. , require(), Symfony Symfony, -, , - .

, : PageBundle, , , WebmuchPageBundle. routing_dev.yml? :

page:
    resource: "@WebmuchPageBundle/Controller/DefaultController.php"
    type:     annotation

dev test, routing_dev.yml, routing.yml.

, . (, src/Webmuch/PageBundle/WebmuchPageBundle.php) :

namespace Webmuch\PageBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class WebmuchPageBundle extends Bundle
{
}

, , , , - . , , !

+5

. ! , :

webmuch_page_hello_world:
    pattern:   /hello
    defaults: { _controller: PageBundle:Default:hello }

"PageBundle" . "WebmuchPageBundle". : WebmuchPageBundle: : hello

+3

All Articles