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

  1. Add a public newInstance(\Closure $container, array $parameters) method returning an instance.
  2. If SelfBuilding behavior is not intended, remove the interface/extends so the container builds the class normally.
  3. 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 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


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)