【问题标题】:How to only display the $exception->message on the 404 error page when debug=true in .env.env 中 debug=true 时如何仅在 404 错误页面上显示 $exception->message
【发布时间】:2021-11-08 07:45:24
【问题描述】:

我的 404.blade.php 文件是这样的:

@extends('layouts.app')

@section('content')
    <h3 class="page-title">@lang('global.app_oh_no')!</h3>

    <div class="panel panel-default">
        <div class="panel-body">
            <div class="row" >
                <h4>&nbsp;&nbsp;@lang('global.app_sorry_were_not_able_to_find_the_page_you_are_looking_for').</h4>

                <h4> &nbsp;&nbsp;{{$exception->getMessage()}} </h4>
            </div>
        </div>
    </div>

@stop

有人要求我对其进行修改,以便代码 line{{$exception-&gt;getMessage()}} 仅在“debug=true in .env”时显示错误

问题是我不知道这意味着什么或如何处理它。

我的环境。文件设置为 APP_DEBUG=true,我的app.php文件设置为'debug' =&gt; env('APP_DEBUG', false),

那么我该如何修改它以便 $exception->getMessage() 仅在 .env 中的 debug=true 时显示以查看 404 错误问题

这对人们有意义吗,我不知道预期的行动会是什么。我想我无法理解这个概念和行动计划。

【问题讨论】:

    标签: laravel debugging http-status-code-404


    【解决方案1】:

    简单地使用条件

    @if (config('app.debug'))
        {{ $exception->getMessage() }}
    @endif
    

    【讨论】:

    • 感谢您提出的解决方案,我会尝试一下。您是否也可以帮助我了解这里发生了什么?我想我不明白在调试过程中访问的内容和方式以及新解决方案如何修改原始操作。
    猜你喜欢
    • 2015-01-27
    • 2017-10-28
    • 1970-01-01
    • 2018-05-24
    • 2021-11-26
    • 2015-07-22
    • 1970-01-01
    • 2023-01-29
    • 2019-03-17
    相关资源
    最近更新 更多