I know this post is popular in here, there are a lot of questions about this problem, but nothing helped me to solve my problem. I have to ask this.
I created a bundle named "ATL15/GoogleAnalyticsBundle".
I want to get users parameters from app/config.yml; This is my configuration parameters, i'm loading parameters from app/parameters.yml.
atl15_google_analytics:
client_id: "%ga_client_id%"
client_secret: "%ga_client_secret%"
developer_key: "%ga_developer_key%"
redirect_uri: "%ga_redirect_uri%"
I did everything i read from symfony documentation book and the web. Nothing helped me at all...
This is my DependencyInjection/Configuration.php
file:
<?php
namespace ATL15\GoogleAnalyticsBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder,
Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('atl15_google_analytics');
$rootNode->children()
->scalarNode('client_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('client_secret')->isRequired()->cannotBeEmpty()->end()
->scalarNode('developer_key')->isRequired()->cannotBeEmpty()->end()
->scalarNode('redirect_uri')->isRequired()->cannotBeEmpty()->end()
->end();
//var_dump($rootNode); die;
return $treeBuilder;
}
}
And this is my DependencyInjection/ATL15GoogleAnalyticsBundleExtension.php
file:
<?php
namespace ATL15\GoogleAnalyticsBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension,
Symfony\Component\DependencyInjection\Loader;
class ATL15GoogleAnalyticsExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
foreach (array('config') as $basename) {
$loader->load(sprintf('%s.yml', $basename));
}
foreach (array('client_id', 'client_secret', 'developer_key', 'redirect_uri') as $attribute) {
$container->setParameter($attribute, $config[$attribute]);
}
}
public function getAlias()
{
return 'atl15_google_analytics';
}
}
And yes, i loaded this bundle from app/AppKernel.php
;
new ATL15\GoogleAnalyticsBundle\ATL15GoogleAnalyticsBundle(),
Everytime i'm getting this error:
[Sat Sep 14 17:37:24 2013] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' with message 'There is no extension able to load the configuration for "atl15_google_analytics" (in /var/www/vsy-bio/src/ATL15/GoogleAnalyticsBundle/DependencyInjection/../Resources/config/config.yml). Looked for namespace "atl15_google_analytics", found none' in /var/www/vsy-bio/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php:290\nStack trace:\n#0 /var/www/vsy-bio/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php(260): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->validate(Array, '/var/www/vsy-bi...')\n#1 /var/www/vsy-bio/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php(44): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->loadFile('/var/www/vsy-bi...')\n#2 /var/www/vsy-bio/src/ATL15/GoogleAnalyticsBundle/DependencyInjection/ATL15GoogleAnalyticsExtension.php(28): Symfon in /var/www/vsy-bio/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php on line 290
Could you please help me?