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

Viewed 16504

i'm have a router register but i found error

Target [Laravel\Fortify\Contracts\RegisterViewResponse] is not instantiable.

6 Answers

You need to register fortify service provider inside the config/app.php files

Add this

App\Providers\FortifyServiceProvider::class,

to config/app.php under the Application's Service Providers.

Update : It is also important you point the location of your authentication views to Fortify.

An example for the Register view would be:


//  auth.register => means your register.blade is located in `view/auth/`
//  folder. (All things being equal)

Fortify::registerView(function () {
    return view('auth.register');
});

Read More: https://laravel.com/docs/9.x/fortify#registration

you have to add all these in FortifyServiceProvider.php at the boot method. then import all classes needed

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');
        });

after that you need to create the register and login view

Verify that the following providers are registered in the config.app file in the providers section

App\Providers\FortifyServiceProvider::class,
App\Providers\JetstreamServiceProvider::class, // If using Jetstream

Uncomment the following line in the App\Providers\FortifyServiceProvider.php file

Fortify::createUsersUsing(CreateNewUser::class);

Make registerView function on app/providers/FortifyServiceProvider.php

    Fortify::registerView(function () {
        return view('auth.register');
    });

In addition to Joseph Ajibodu's answer, within the boot method of FortifyServiceProvider add the following:

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

    Fortify::registerView(function () {
        return view('auth.register');
    });

    Fortify::requestPasswordResetLinkView(function () {
        return view('auth.forgot-password');
    });

    Fortify::resetPasswordView(function () {
        return view('auth.reset-password');
    });

Fortify::registerView(function () { return view('auth.register');

put this code in your fortyfive service provider folder under the book method

Related