Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager

13,573

Solution 1

This refers to this Laravel issue which is not an issue :)

Don't ask me why, but you are probably missing the following provider:

Illuminate\Notifications\NotificationServiceProvider::class

Solution 2

I also had the sam approach as yours. I excluded non default packages and upgraded and got same error.

You must add

Illuminate\Notifications\NotificationServiceProvider::class

to your

config/app.php

file. In my case that worked.

Share:
13,573

Related videos on Youtube

nowox
Author by

nowox

Software and Electronic Engineer specialized in MotionControl applications.

Updated on June 04, 2022

Comments

  • nowox
    nowox over 1 year

    I am trying to implement Laravel without templates in a minimal fashion. Actually I would like to migrate a Non-Laravel project and do it step by step.

    require_once __dir__ . '/../vendor/autoload.php';
    
    $app = new Application($_ENV['APP_BASE_PATH'] ?? dirname(__DIR__));
    
    $app->singleton(
        Illuminate\Contracts\Http\Kernel::class,
        App\Kernel::class
    );
    
    $app->singleton(
        Illuminate\Contracts\Debug\ExceptionHandler::class,
        App\Exceptions\Handler::class
    );
    
    $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
    
    $request = \Illuminate\Http\Request::capture();
    $app->instance('request', $request);
    
    $app->bootstrapWith($this->bootstrappers);
    
    $app->boot();
    

    Everything works fine except for the bootstrapper:

    \Illuminate\Foundation\Bootstrap\RegisterProviders::class,
    

    Which will load Illuminate\Support\Manager. By digging a bit I found that Manager's constructor is:

    public function __construct($app)
    {
        $this->app = $app;
    }
    

    And Laravel cannot resolve the dependencies of $app. However if I monkey patch this constructor with the following, then it works.

    public function __construct(\Illuminate\Foundation\Application $app)
    

    How does Laravel resolve the dependency injection for $app and why isn't working in my case?

  • nowox
    nowox almost 5 years
    Oh ! Sorry, this is my mistake.. I did some copy/paste to write the question. I fixed it
  • Peter Szalay
    Peter Szalay over 4 years
    Thanks nowox, this wasn't in the upgrade guide!
  • Tenaciousd93
    Tenaciousd93 over 1 year
    Save my day, twice :)