简体   繁体   English

在Laravel存储库上找不到ReflectionException类

[英]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: 控制器ProductController.php如下所示:

<?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: 存储库ProductRepository.php位于:

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. 我已经在每个Laravel论坛和Stack上搜索了答案,但是没有一种解决方案有效。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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