Reputation: 134
<?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?
Upvotes: 4
Views: 18633
Reputation: 1
Just refactor UserRepository
class to for example MyUserRepository
, only this one solved my problem
Upvotes: 0
Reputation: 351
Change your composer.json file.
"autoload": {
"autoload": {
"classmap": [
"database",
"app/Repositories"
],
composer dump-autoload
=> Done
Upvotes: 1
Reputation: 449
I had such problem when I tried to re-install Bagisto (on Laravel). I deleted the .env file in the project root and this solved the issue.
Upvotes: 0
Reputation: 9691
If someone is facing this error. I think, you may get this error, if your Repository class is not able to access your model, just add use App\User;
at top and the error should go.
Upvotes: 0
Reputation: 633
If you have some syntax errors in that class, the message is the same as class not found.
Upvotes: 0
Reputation: 441
Make sure your class namespace is correct or you can also run this command below
composer dump-autoload
Upvotes: 0
Reputation: 1617
in case seems like this, delete the vendor folder and re-install composer
composer install
Upvotes: 0
Reputation: 3665
The strange thing I had when such error occurred is that I had space between keyword namespace
and App\Repositories;
Once removed, it all worked fine!
Upvotes: 0
Reputation: 577
you would want to do composer dump-autoload
and it will fix your issue
given that you have all your namespaces / class names correctly
Upvotes: 1
Reputation: 19285
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
Upvotes: 5