在Laravel知识库中找不到ReflectionException类
问题描述:
我收到了存储库上引发的反射异常。我根本无法找到解决方案或为什么抛出异常。我检查了四次拼写,四次检查了案例,四次检查了命名空间。我得到的错误是:在Laravel知识库中找不到ReflectionException类
ReflectionException in Container.php line 731: Class App\Repositories\ProductRepository does not exist
控制器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...
}
储存库ProductRepository.php是:
App\Repositories
看起来像这样:
<?php
namespace App\Repositories;
class ProductRepository {
public function getProducts(){
//Some Query
}
}
我已经搜遍了每个Laravel论坛和Stack的答案,但没有一个解决方案奏效。我一直在努力寻找一个解决方案的时间,我根本无法理解课程是如何被识别的。任何想法,我可能会错过这里?
答
我没有看到任何错误在这里,所以这是可能的,你应该运行
composer dump-autoload
,以确保您的类是可见的。
也许你也应该删除使用
php artisan clear-compiled
感谢您的答复有些缓存。我在过去一小时内运行了'composer dump-autoload','php artisan cache:clear'和'php artisan clear-compiled'约100次。什么都没有 –
@BillDukelow任何你有文件名中有空格的机会?例如在文件的开头或结尾?寻找错别字,尝试再次创建文件 –
雅我刚刚检查,并没有空格。我刚刚删除了Repositories目录并重新创建了目录和文件。还是一样的错误。 –