moodle/moodle · error · InvalidDefinition
Entry " " cannot be compiled. Invokable classes cannot be…
Error message
Entry "%s" cannot be compiled. Invokable classes cannot be automatically resolved if autowiring is disabled on the container, you need to enable autowiring or define the entry
What it means
Error "Entry "%s" cannot be compiled. Invokable classes cannot be automatically resolved if autowiring is disabled on the container, you need to enable autowiring or define the entry" thrown in moodle/moodle.
Solutions
- Enable autowiring on the container so invokable classes can be resolved
- Define the entry explicitly (object definition or factory) instead of relying on autowiring
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at public/lib/php-di/php-di/src/Compiler/Compiler.php:273 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14).
Data as JSON: /api/errors/dd0915a1b8fbe1b1.
Report an issue: GitHub.
Appendix: source
Thrown at public/lib/php-di/php-di/src/Compiler/Compiler.php:273
}
throw new InvalidDefinition(sprintf(
'Entry "%s" decorates nothing: no previous definition with the same name was found',
$definition->getName()
));
}
$code = sprintf(
'return call_user_func(%s, %s, $this->delegateContainer);',
$this->compileValue($definition->getCallable()),
$this->compileValue($decoratedDefinition)
);
break;
case $definition instanceof FactoryDefinition:
$value = $definition->getCallable();
// Custom error message to help debugging
$isInvokableClass = is_string($value) && class_exists($value) && method_exists($value, '__invoke');
if ($isInvokableClass && !$this->autowiringEnabled) {
throw new InvalidDefinition(sprintf(
'Entry "%s" cannot be compiled. Invokable classes cannot be automatically resolved if autowiring is disabled on the container, you need to enable autowiring or define the entry manually.',
$entryName
));
}
$definitionParameters = '';
if (!empty($definition->getParameters())) {
$definitionParameters = ', ' . $this->compileValue($definition->getParameters());
}
$code = sprintf(
'return $this->resolveFactory(%s, %s%s);',
$this->compileValue($value),
var_export($entryName, true),
$definitionParameters
);
break;View on GitHub (pinned to 48ea8c3322)