Laravel 5 - Interface is not instantiable

Laravel 5 - Interface is not instantiable

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Resolving "Interface is not instantiable" in Laravel 5

When you encounter a BindingResolutionException stating that a target like App\Contracts\CustomModelInterface is not instantiable, the error message is technically accurate but often misleading to junior developers. The container isn't failing because your interface definition is broken; it's failing because you are trying to bind an interface to itself without providing an implementation for the container to resolve.

In Laravel 5, the Service Provider pattern relies on explicit binding in the register() method. However, a common pitfall occurs when developers attempt to bind an abstract class or interface directly to itself using dynamic strings in a loop, as shown in the source material's provider:

foreach ($models as $idx => $model) {
    $this->app->bind("App\Contracts\{$model}Interface", "App\Repositories\{$model}Repository");
}

This specific line of code is where the logic breaks. When you call $this->app->bind($abstract, $concrete), Laravel expects the $abstract name to be a concrete class or interface that can eventually be resolved. If your dependency injection graph requires MyService to receive an instance of CustomModelInterface, Laravel looks for a binding where the key is App\Contracts\CustomModelInterface.

However, if your controller or service constructor relies on type hinting against App\Contracts\CustomModelInterface, and you haven't explicitly bound that specific string in the provider, Laravel falls back to looking for a class with that exact name. Since interfaces cannot be instantiated directly, the container throws the "not instantiable" exception.

The root cause in the provided scenario is likely a mismatch between how the binding is registered and how the service expects to be resolved. In modern Laravel 5 projects (and subsequent versions), the standard approach discourages manual string binding for simple interfaces unless you have multiple concrete implementations that need to be injected conditionally.

Correcting the Provider Binding

To fix this, you should explicitly bind the interface to its implementation using fully qualified class names rather than constructing strings dynamically. This ensures clarity and prevents scope resolution issues. Update your AppRepositoryProvider as follows:

namespace App\Providers;

use App\Contracts\CustomModelInterface;
use App\Repositories\CustomModelRepository;
use Illuminate\Support\ServiceProvider;

class AppRepositoryProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->bind(
            CustomModelInterface::class,
            CustomModelRepository::class
        );
    }

    public function boot()
    {
        // Boot logic here
    }
}

By using CustomModelInterface::class, you are telling the container: "Whenever code requests an instance of CustomModelInterface, give them an instance of CustomModelRepository." This removes ambiguity. The previous dynamic string approach worked only if the exact string matched a registered binding, but it is fragile and harder to debug when typos occur in the class names.

Why Type Hinting Interfaces Matters

The source material mentions that "everything works if I replace interfaces on repositories in MyService." While this resolves the immediate error, it violates the core philosophy of dependency injection. Replacing an interface with a concrete model in your constructor changes the coupling of your application. If you later decide to switch from CustomModel to CustomModel2, you would have to update every service that references the concrete class.

Keeping the type hint as CustomModelInterface allows your MyService to remain agnostic of the underlying implementation. The container handles the resolution behind the scenes, allowing for easier testing and swapping of implementations later on.

Common Pitfalls in Laravel 5 Injection

When debugging these issues, remember that Laravel's autoloading (configured via composer.json) ensures the classes exist, but it does not automatically resolve interfaces to implementations. The container must be told explicitly which implementation satisfies a specific interface contract. If you rely on loose coupling without explicit binding, or if you forget to bind an interface in a specific service provider that is loaded early, you will hit this exception immediately upon instantiation of any dependent class.

Additionally, ensure that your AppRepositoryProvider is actually registered in the app.php configuration file under the providers key. Without this registration, the register() method never executes, leaving the container unaware of your custom bindings.

Our network