BindingResolutionException with all response() calls in 7.x

Viewed 288
  • Lumen Version: 7.1.2
  • Laravel Version: 7.12.0 (happens with all 7.x versions)
  • PHP Version: 7.4.6
  • Database Driver & Version: mysqlnd 7.4.6

Description:

All routes return error:

Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Routing\RouteCollectionInterface] is not instantiable while building [Illuminate\Routing\Redirector, Illuminate\Routing\UrlGenerator]. in /home/harold/projects/work/git/sugar-api/vendor/laravel/framework/src/Illuminate/Container/Container.php:1011

Routes work fine with Lumen 6.x, but appear to have problems with the changes to the class Illuminate\Routing\UrlGenerator from Laravel 7.12.0.

Steps To Reproduce:

Fresh install, then I have a route whose controller simply responds: return response()->json($model).

The AppServiceProvider.php has the following as instructed here for Lumen, and it's Illuminate\Routing\Redirector that loads the Illuminate\Routing\UrlGenerator:

    public function register()
    {
        $this->app->singleton('Illuminate\Contracts\Routing\ResponseFactory', function ($app) {
            return new \Illuminate\Routing\ResponseFactory(
                $app['Illuminate\Contracts\View\Factory'],
                $app['Illuminate\Routing\Redirector']
            );
        });
    }
0 Answers
Related