【问题标题】:Route ErrorException for Local Laravel Project but not Production Project?本地 Laravel 项目但不是生产项目的路由错误异常?
【发布时间】:2017-08-05 17:25:09
【问题描述】:

在我的本地 Laravel 项目中,如果我访问 url http://local.website.com/share/show/372/3149,3150 我得到错误:

[2017-03-15 14:05:16] production.ERROR: 异常 'ErrorException' 和 /home/vagrant/Code/RP/storage/framework/views/e48b285e80e2612c5de297f7900a6e0c9933aec4.php 中的消息 'Undefined variable: class' :74
堆栈跟踪:
#0 /home/vagrant/Code/RP/storage/framework/views/e48b285e80e2612c5de297f7900a6e0c9933aec4.php(74): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined varia...', '/home/vagrant /C...', 74, 数组)

但是在我的生产 Laravel 项目中,如果我访问 url http://website.com/share/show/372/3149,3150 我没有收到任何错误并且视图显示。

生产 url 指向我的实时 VPS Cent 操作系统。我的本地设置在 Windows 10 上,但在 Homestead 中运行。两个项目都使用完全相同的代码。

这里可能出了什么问题?我需要清除工匠缓存吗?任何建议都会非常有帮助。

编辑:添加e48b285e80e2612c5de297f7900a6e0c9933aec4.php导致错误的代码行:

<td class="text-center status<?=$class?>"> <!-- Line 74 -->
    <?=$res?>
</td>

【问题讨论】:

  • 你能在e48b285e80e2612c5de297f7900a6e0c9933aec4.php中显示使用第74行吗?
  • @DestinationN 请查看使用代码编辑
  • 你从哪里得到$class变量值
  • &lt;td class="text-center status{{$class or "None"}}&gt;"&gt; &lt;!-- Line 74 --&gt; {{$res}} &lt;/td&gt;
  • @kaiogita 没有,因为e48b285e80e2612c5de297f7900a6e0c9933aec4.php 是 laravel 编译的视图。在未编译的视图中,他已经使用{{ 和}} 来包装他的php

标签: php laravel laravel-5


【解决方案1】:

检查您的 $class 变量是从您的视图中定义的还是从您的视图中传递的 你的控制器喜欢

return view('myview', compact('class')); //or
return view('greeting')->with('class', 'English');

提示:向视图传递数据时使用刀片

{{$class}}

【讨论】:

  • 我投了反对票,因为我在提醒您,您在传递数据时可能有错误?
猜你喜欢
  • 2021-07-09
  • 2013-02-09
  • 2017-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多