There is no extension able to load the configuration for "facebookbundle" symfony2

Solution 1:

Also, keep in mind that the root key of the configuration file must be a normalized form of the Bundle's name.

This is something I've encoutered a few times and it's very frustrating to solve if you're not aware of it.

Example: if bundle is called MyFirstAwesomeBundle, then the root key in the file must be my_first_awesome. So camel-case is converted to snake-case and the word "bundle" is ignored or stripped away.

So simply having the root key in your file match exactly the value specified in Configuration::getConfigTreeBuilder() is not enough.

If you don't follow this rule, then you'll get the There is no extension able to load the configuration error.


I hope this will help the next desperate soul who ends up on this page...

Solution 2:

In order for custom config parameters to be accepted you have to define your bundle configuration using a Configuration.php class within your bundle.

src/FacebookBundle/DependencyInjection/Configuration.php:

<?php
namespace FacebookBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * This is the class that validates and merges configuration from your app/config files
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
 */
class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('facebookbundle');

        $rootNode
            ->children()
                ->scalarNode('file')->defaultValue('')->end()
                ->scalarNode('alias')->defaultValue('')->end()
                ->scalarNode('app_id')->defaultValue('')->end()
                ->scalarNode('secret')->defaultValue('')->end()
                ->booleanNode('cookie')->defaultTrue()->end()
                ->arrayNode('permissions')
                    ->canBeUnset()->prototype('scalar')->end()->end()
            ->end()
            ;

        return $treeBuilder;
    }
}
?>

Solution 3:

This happens when you forget to start the bundle in app/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\DoctrineBundle\DoctrineBundle(),
              new Symfony\Bundle\AsseticBundle\AsseticBundle(),
              new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
              new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
              //...
              new D\FacebookBundle\DFacebookBundle(),
              //...
      );

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

}

Solution 4:

This error can also be caused by a missing or invalid services key at the root of your config. It should look something like this:

services:
    foo_bar.baz:
        class: Foo\BarBundle\Service\BazService