Missing Parameter Error
Overview This issue occurs when the system reports that a required parameter is missing, usually in the console during container compilation or when executing commands. It is often encountered in extensions or plugins that register custom resources, forms, or routes.
Symptom
You may see an error like the following:
You have requested a non-existent parameter "%your-parameter%"
# or
Missing required resource parameter in container configuration
This typically indicates that some parameters are loaded too late in the container lifecycle.
Cause
The error usually happens because:
Resource configurations are registered in the
load()
method after services that depend on them.Parameters for forms, routes, or resources are not yet available when other parts of the container are being initialized.
The order of configuration processing in the extension is incorrect.
Solution
To fix the issue, you should move resource registration and parameter setup earlier, so that they are available before dependent services are loaded. This can be done by using the prepend()
method in your extension:
Key Steps:
Use
load()
mainly for:Loading service definitions (
services.xml
)
Use
prepend()
to:Setting parameters (forms, routes)
Register resources with
registerResources()
Prepend any additional extension configuration
Example Conceptual Code (YourPluginExtension.php)
Before:
public function load(array $configs, ContainerBuilder $container): void
{
// ...
$container->setParameter('your_plugin.parameter', $config['parameter']);
$this->registerResources(
'your_plugin',
SyliusResourceBundle::DRIVER_DOCTRINE_ORM,
$config['resources'],
$container,
);
}
public function prepend(ContainerBuilder $container): void
{
$container->prependExtensionConfig(...);
}
After:
public function load(array $configs, ContainerBuilder $container): void
{
// Only load services that do not depend on resource parameters
}
public function prepend(ContainerBuilder $container): void
{
$config = $this->getCurrentConfiguration($container);
$container->setParameter('your_plugin.parameter', $config['parameter']);
$this->registerResources(
'your_plugin',
SyliusResourceBundle::DRIVER_DOCTRINE_ORM,
$config['resources'],
$container
);
$container->prependExtensionConfig(...);
}
private function getCurrentConfiguration(ContainerBuilder $container): array
{
$configuration = $this->getConfiguration([], $container);
$configs = $container->getExtensionConfig($this->getAlias());
return $this->processConfiguration($configuration, $configs);
}
Takeaways
Always register resources and their parameters early in the container lifecycle.
prepend()
is the preferred place for resource registration and modifying other extension configurations.Keep
load()
focused on setting parameters and loading services that don’t depend on other resources.Following this pattern avoids the “non-existent parameter” error and ensures your plugin or extension works reliably.
Last updated
Was this helpful?