laravel/framework · error · BindingResolutionException
No newInstance method exists for [$concrete].
Error message
No newInstance method exists for [$concrete].
What it means
Thrown by Container::buildSelfBuildingInstance when a class implements the SelfBuilding contract (so the container delegates instantiation to it) but the class does not declare the required newInstance method. SelfBuilding types are expected to expose newInstance(\Illuminate\Container\Container, array) so the container can call it to build the instance.
Source
Thrown at src/Illuminate/Container/Container.php:1211
return $instance;
}
/**
* Instantiate a concrete instance of the given self building type.
*
* @template TClass of object
*
* @param object{'newInstance': \Closure(static, array): TClass|class-string<TClass>} $concrete
* @param \ReflectionClass $reflector
* @return TClass
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
protected function buildSelfBuildingInstance($concrete, $reflector)
{
if (! method_exists($concrete, 'newInstance')) {
throw new BindingResolutionException("No newInstance method exists for [$concrete].");
}
$this->buildStack[] = $concrete;
$instance = $this->call([$concrete, 'newInstance']);
array_pop($this->buildStack);
$this->fireAfterResolvingAttributeCallbacks(
$reflector->getAttributes(), $instance
);
return $instance;
}
/**
* Resolve all of the dependencies from the ReflectionParameters.
*View on GitHub (pinned to bd6b5437e6)
Solutions
- Add a public instance method `public function newInstance(Container $container, array $parameters = []): static` (or matching signature) to the SelfBuilding class.
- If you no longer want container-managed construction, remove the SelfBuilding interface from the class.
- Ensure the method is public and not static-only — method_exists must see an instance-callable method.
Example fix
// before
class Money implements \Illuminate\Contracts\Container\SelfBuilding
{
// newInstance missing
}
// after
class Money implements \Illuminate\Contracts\Container\SelfBuilding
{
public function newInstance(\Illuminate\Container\Container $container, array $parameters = []): static
{
return new self($parameters['amount'] ?? 0);
}
} Defensive patterns
Strategy: validation
Validate before calling
if (is_a($class, \Illuminate\Contracts\Container\SelfBuilding::class, true)
&& ! method_exists($class, 'newInstance')) {
throw new \LogicException("{$class} implements SelfBuilding but has no newInstance method");
}
app()->make($class); Type guard
function hasSelfBuildingFactory(string $class): bool
{
return ! is_a($class, \Illuminate\Contracts\Container\SelfBuilding::class, true)
|| method_exists($class, 'newInstance');
} Prevention
- Pair SelfBuilding with a contract test asserting newInstance exists.
- Remove SelfBuilding if you no longer need container-managed construction.
- Use IDE templates for SelfBuilding classes.
When it happens
Trigger: A class implements Illuminate\Contracts\Container\SelfBuilding but the developer removed or renamed the newInstance method, or declared it private/static/wrongly-typed so method_exists returns false (note: method_exists checks visibility-correct existence).
Common situations: Custom value objects/DTOs that opt into SelfBuilding for container-managed construction; refactoring a SelfBuilding class and forgetting newInstance; partial copy of an interface implementation.
Related errors
- Method not provided.
- Unable to resolve dependency [{$parameter}] in class {$param
- {self::class}::bind(): Argument #2 ($concrete) must be of ty
- [{$abstract}] is aliased to itself.
- Target class [$concrete] does not exist.
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/1c530a131fcd65f2.json.
Report an issue: GitHub.