Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class App\Repositories\UserRepository does not exist

<?php

namespace App\Http\Controllers;


use Illuminate\Contracts\Auth\Guard;
use Laravel\Socialite\Contracts\Factory as Socialite; 
use App\Repositories\UserRepository;


class SocialController extends Controller
{
    /**
     * Redirect the user to the GitHub authentication page.
     *
     * @return Response
     */

    private $socialite;
     private $auth;
     private $users;

     public function __construct(Socialite $socialite, Guard $auth, UserRepository $users) {   
        $this->socialite = $socialite;
        $this->users = $users;
        $this->auth = $auth;
    }
}

This is my controller. While I'm loading this controller it showing an error like

"ReflectionException in Container.php line 791: Class App\Repositories\UserRepository does not exist".

Can anyone suggest me a solution?

like image 473
Neethu Avatar asked Oct 14 '25 04:10

Neethu


2 Answers

Probably a namespace issue

Check the path of your UserRepository file class. It should be:

app/Repositories/UserRepository.php

And inside the class file you need to use this namespace:

namespace App/Repositories;

This should work

like image 172
Moppo Avatar answered Oct 16 '25 21:10

Moppo


you would want to do composer dump-autoload and it will fix your issue given that you have all your namespaces / class names correctly

like image 28
Sari Yono Avatar answered Oct 16 '25 21:10

Sari Yono



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!