简体   繁体   中英

ReflectionException Class Not Found on Laravel Repository

I'm getting a reflection exception thrown on a repository. I simply cannot find the solution or why the exception is being thrown. I have quadruple checked the spelling, quadruple checked the case and quadruple checked the namespacing. The error I get is the following:

ReflectionException in Container.php line 731: Class App\\Repositories\\ProductRepository does not exist

The controller ProductController.php looks like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Repositories\ProductRepository;

class ProductsController extends Controller
{


protected $product;

public function __construct(ProductRepository $product){

    $this->product = $product;

}

//Other Methods...
}

The repository ProductRepository.php is in:

App\\Repositories

and looks like this:

<?php

namespace App\Repositories;

class ProductRepository {

public function getProducts(){
//Some Query
}

}

I've scoured every Laravel forum and Stack for the answer but none of the solutions have worked. I've been hours trying to find a solution and I simply cannot fathom how the class is not being recognised. Any ideas what I could be missing here?

I don't see any error here, so it's possible you should run

composer dump-autoload

to make sure your class is visible.

Maybe you should also remove some cache using

php artisan clear-compiled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM