dongxingchang9345 2017-02-24 21:22
浏览 99

在Laravel存储库中找不到ReflectionException类

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?

  • 写回答

1条回答 默认 最新

  • dongtuji0992 2017-02-24 21:46
    关注

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)