この投稿がここで人気があることは知っています。この問題について多くの質問がありますが、問題を解決するのに役立つものは何もありませんでした. 私はこれを尋ねなければなりません。
「ATL15/GoogleAnalyticsBundle」という名前のバンドルを作成しました。
app/config.yml からユーザー パラメータを取得したい。これは私の設定パラメータです。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%"
symfony のドキュメンテーション ブックと Web から読んだことはすべて実行しました。何も役に立たなかった...
これは私のDependencyInjection/Configuration.php
ファイルです:
<?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;
}
}
そして、これは私のDependencyInjection/ATL15GoogleAnalyticsBundleExtension.php
ファイルです:
<?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';
}
}
はい、このバンドルを からロードしましたapp/AppKernel.php
。
new ATL15\GoogleAnalyticsBundle\ATL15GoogleAnalyticsBundle(),
このエラーが発生するたびに:
[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 can load the configuration for "atl15_google_analytics" (/var/www/vsy-bio/src/ATL15/GoogleAnalyticsBundle/DependencyInjection/../Resources/config/config.yml 内)。名前空間「atl15_google_analytics」を探しましたが、/var/www/vsy-bio/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php:290 に見つかりませんでした:290\nスタック トレース:\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...」
手伝っていただけませんか?