hamiha's avatar
Level 17

Target [Illuminate\Contracts\Routing\UrlGenerator] is not instantiable

I am using Laravel Lumen 5.3.

I'm having problem with core Password reset function, which calls url() function.

Line, where error occurs:

$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
        $message->subject('Your Password Reset Link');
    });

Response error that i get:

Target [Illuminate\Contracts\Routing\UrlGenerator] is not instantiable

Following error log, it leads to this piece of code in lumen-framework\src\helpers.php

function url($path = null, $parameters = [], $secure = null)
{
    return (new Laravel\Lumen\Routing\UrlGenerator(app()))
                            ->to($path, $parameters, $secure);
}

which means that we need to register additional providers in AppServiceProvider like this:

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

Thanks for your help.

0 likes
0 replies

Please or to participate in this conversation.