【问题标题】:Laravel 4 model not found未找到 Laravel 4 模型
【发布时间】:2014-03-05 16:23:56
【问题描述】:

我有这个模型文件:

\app\models\Recipe.php

<? php

class Recipe extends Eloquent{
    protected $table = 'recipes';
}

这是我的控制器:

<?php
class IndexController extends BaseController {

    public function showIndex()
    {
        $recipes = Recipe::all();
    return View::make('index',array('recipes' => $recipes));
    }

}

当我尝试调用该页面时,我收到此错误消息:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Recipe' not found

我也执行了

composer dump-autoload

知道有什么问题吗?

【问题讨论】:

  • 你的源代码真的是&lt;? php而不是&lt;?php吗?

标签: php model frameworks laravel


【解决方案1】:

如果你的Recipe.php是直接复制粘贴的。

<? php 
   class Recipe extends Eloquent{
      protected $table = 'recipes';
   }

然后就坏了,因为PHP标签不对。它必须是 &lt;?php 而不是 &lt;? php 它只是作为文件而不是 php 文件读取。

【讨论】:

  • 哎哟...抱歉
猜你喜欢
  • 2012-12-26
  • 1970-01-01
  • 2017-02-09
  • 1970-01-01
  • 2015-11-16
  • 1970-01-01
  • 2017-04-11
  • 1970-01-01
相关资源
最近更新 更多