laravel/framework · error · BindingResolutionException
No newInstance method exists for [$concrete].
Error message
No newInstance method exists for [$concrete].
What it means
BindingResolutionException from buildSelfBuildingInstance() when a concrete implementing the SelfBuilding contract does not declare the required newInstance() method. The SelfBuilding path delegates construction to newInstance(); without it the contract cannot be honored.
Solutions
- Add a public newInstance(\Closure $container, array $parameters) method returning an instance.
- If SelfBuilding behavior is not intended, remove the interface/extends so the container builds the class normally.
- Verify method visibility - newInstance must be public and callable via the container.
Example fix
// before
class ReportFactory implements SelfBuilding
{
// missing newInstance
}
// after
class ReportFactory implements SelfBuilding
{
public function newInstance(Container $container, array $parameters = []): static
{
return new static(...$parameters);
}
} Defensive patterns
Strategy: type-guard
Validate before calling
if (is_a($concrete, \Illuminate\Contracts\Container\SelfBuilding::class, true)
&& ! method_exists($concrete, 'newInstance')) {
throw new RuntimeException("SelfBuilding class [$concrete] must implement newInstance().");
}
$container->make($concrete); Type guard
function selfBuilderIsComplete(string $class): bool
{
return is_a($class, \Illuminate\Contracts\Container\SelfBuilding::class, true)
&& method_exists($class, 'newInstance');
} Try / catch
use Illuminate\Contracts\Container\BindingResolutionException;
try {
$instance = $container->make($class);
} catch (BindingResolutionException $e) {
if (str_contains($e->getMessage(), 'No newInstance method')) {
// add newInstance() or drop the SelfBuilding interface
}
throw $e;
} Prevention
- When adopting SelfBuilding, scaffold newInstance() via an IDE live template.
- Static-analysis contract completeness so partial implementations fail at CI time.
- Avoid deleting newInstance() during refactors; mark it @internal/@required in docblocks.
When it happens
Trigger: A class implements Illuminate\Contracts\Container\SelfBuilding (or is_a SelfBuilding::class) but omits the newInstance method; a class was renamed/changed and the method was dropped; partial implementation of the contract.
Common situations: Adopting the SelfBuilding feature without completing the contract; IDE-assisted refactor deleting an 'unused' newInstance method; copy-paste of a SelfBuilding class with the method stripped.
Related errors
- Contextual binding attribute
- {$id}
- Illuminate\Container\Container::bind(): Argument #2…
- Method not provided.
- Target [$concrete] is not instantiable.
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/1c530a131fcd65f2.
Report an issue: GitHub.
Appendix: 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 e0f6eb3518)