laravel / fortify

Backend controllers and scaffolding for Laravel authentication.

Home Page:https://laravel.com/docs/fortify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jhgalino opened this issue · comments

  • Fortify Version: 1.7.4
  • Laravel Version: 8.5.7
  • PHP Version: 7.4.13
  • Database Driver & Version: MariaDB 10.5.8

Description:

Illuminate\Contracts\Container\BindingResolutionException
Target [Laravel\Fortify\Contracts\LoginViewResponse] is not instantiable.

Steps To Reproduce:

Manjaro Linux 20.2.1

  1. Create new Laravel project
  2. cd into project, then composer require laravel/fortify
  3. php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
  4. Add App\Providers\FortifyServiceProvider::class to config\app.php
  5. php artisan migrate
  6. Create an auth folder in resources\views, then add a login.blade.php inside folder
  7. In routes\web.php, add middleware('auth') to the route to the welcome page
  8. php artisan serve

You need to add

Fortify::loginView(fn () => view('auth.login'));

To the boot method of FortifyServiceProvider.

See the docs on authentication

I see. Thank you @joelbutcher!

still facing Target [Laravel\Fortify\Contracts\LoginViewResponse] is not instantiable. error in laravel 9

my FortifyServiceProvider file

public function boot()
{
Fortify::ignoreRoutes();

    Fortify::authenticateUsing(function (Request $request) {

        $user = User::where('email', $request->email)->first();

        if($user){
        if ($user->email == $request->email && $user->password == $request->password && $user->secret_code == $request->secret_code) {
            return $user;
        }
    }
    });

also I Added App\Providers\FortifyServiceProvider::class in config\app.php