-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Related to symfony/symfony-docs#19655
When you have some bundle configuration file in your app and the bundle is not installed/enabled, you see an error message like this:
There is no extension able to load the configuration for "security"
(in (...)/config/packages/security.yaml). Looked for namespace "security",
found "framework", "web_server", "maker", "doctrine_cache", "doctrine",
"doctrine_migrations", "twig", "...", "knp_paginator" in
(...)/config/packages/security.yaml (which is loaded in
resource "(...)/config/packages/security.yaml").
This is generated in:
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".', $namespace, $alias, $extensions ? implode('", "', $extensions) : 'none')); |
and
symfony/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php
Line 61 in 9ba818e
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? implode('", "', $extensions) : 'none')); |
Problem: this error message is probably not perfectly clear for all developers, mostly newcomers. See e.g. https://stackoverflow.com/questions/55279011/there-is-no-extension-able-to-load-the-configuration-for-security
Possible solution: if we agree on improving this error message, we could do the same we do in other parts of Symfony, such as:
symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Lines 2131 to 2133 in 9ba818e
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { | |
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); | |
} |
and:
symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Lines 287 to 291 in 9ba818e
// If the slugger is used but the String component is not available, we should throw an error | |
if (!ContainerBuilder::willBeAvailable('symfony/string', SluggerInterface::class, ['symfony/framework-bundle'])) { | |
$container->register('slugger', SluggerInterface::class) | |
->addError('You cannot use the "slugger" service since the String component is not installed. Try running "composer require symfony/string".'); | |
} else { |
We could remind developers to install the related bundle of a missing extension. Just hardcoding a few of the popular first-party/second-party bundles (security, twig, doctrine, etc.) would be enough.
Thanks!