[Solved] target [Laravel\Fortify\Contracts\RegisterViewResponse] is not instantiable

Laravel Tarif Hossain

Problem: 

We use Fortify for authentication in Laravel 8 but sometimes we got this error.

L8 : Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable.


Solution 1:

Make sure that you are registering the service providers in config/app.php:

App\Providers\FortifyServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,

Solution 2:

You have to add all these in FortifyServiceProvider.php at the boot method.

Fortify::loginView(function(){
            return view('auth.login');
        });

        Fortify::authenticateUsing(function(Request $request){
            $user = User::where('email',$request->email)->first();
            if($user && Hash::check($request->password,$user->password)){
                return $user;
            }
        });
         Fortify::registerView(function(){
            return view('auth.register');
        });

Lastly, leave a comment if you get any questions and wish this article may help you.