在Lumen中找不到具有模型的类

时间:2015-08-29 12:48:51

标签: laravel lumen

在我的网络浏览器中,我收到此错误:

  

UserController.php第18行中的FatalErrorException:

     

Class'App \ Report'   找不到

似乎UserControler.php页面找不到report.php页面。

这是我的文件夹结构:

lumen
-api
--report.php // file where model Report is
---Http
----Controller
------UserController.php // file where i get error
-bootstrap
- ...

UserController.php的标题

namespace App\Http\Controllers;

use Illuminate\Database\Schema\Blueprint;  
use App\Report; // it seems here is problem
use App\User; // with user model is same problem
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;

class UserController extends Controller {
...

report.php的标题

namespace App;
use Illuminate\Database\Eloquent\Model;
class Report extends Model {
...

我正在使用Apache,Ubuntu,PHP 5.5和Lumen框架

1 个答案:

答案 0 :(得分:1)

首先,模型文件名应与此处的类名相同

lumen
-api
--report.php // This should be Report.php
---Http
----Controller
------UserController.php // file where i get error
-bootstrap
- ...

Report.php 模型也位于 app directory same directory where your User Model resides