php Laravel 5 - env local debug true 未显示错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27192237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:13:46  来源:igfitidea点击:

Laravel 5 - env local debug true no errors shown

phpdebugginglaravelenvlaravel-5

提问by peppeocchi

I'm trying to enable the debug for my app but it looks like I don't have any feedback.

我正在尝试为我的应用程序启用调试,但看起来我没有任何反馈。

The environment is set to local (in the .env file) and if I run

环境设置为本地(在 .env 文件中),如果我运行

php artisan env

I get this

我明白了

Current application environment: local

The debug config for my local env is set to true

我的本地环境的调试配置设置为 true

return [

    'debug' => true,

Also if I set in my main config file (app.php inside the config folder) the debug = trueI still have ho feedback that there is an error in the code.

此外,如果我在主配置文件(config 文件夹内的 app.php)中进行设置,debug = true我仍然会收到代码中存在错误的反馈。

I only have an empty page if there is an error in the code (as for debug = false)

如果代码中有错误,我只有一个空页面(至于 debug = false)

What am I missing?

我错过了什么?

回答by Aleksei Akireikin

I have worked around the issue by chmod -R 777 storage/on my host machine (Mac OS X). On my guest machine (Ubuntu 14.04) chmod -R 777 storage/did not change permissions actually.

我已经chmod -R 777 storage/在我的主机(Mac OS X)上解决了这个问题。在我的来宾机器(Ubuntu 14.04)上chmod -R 777 storage/实际上并没有改变权限。

回答by phaberest

php artisan optimizeand if it still does not work delete the file storage/meta/compiled.phpas mentioned in a forum topic on Laracasts

php artisan optimize如果它仍然不起作用,请删除Laracasts 论坛主题中storage/meta/compiled.php提到的文件

I had the same problem and the artisancommand did the trick.

我遇到了同样的问题,artisan命令成功了。

UPDATE

更新

I found out that a nice way to workaround storage folder related issues is to set www-data as its owner. I'm using two commands:

我发现解决存储文件夹相关问题的一个好方法是将 www-data 设置为其所有者。我正在使用两个命令:

sudo chown $(whoami):www-data . -R

and

sudo chown www-data: storage -R

From Laravel 5.1 it may be necessary to do this last command on bootstrap folder too.

从 Laravel 5.1 开始,可能还需要在 bootstrap 文件夹上执行最后一个命令。

回答by Blair

I had a situation where I had the exact same symptom, some routes were not providing any feedback, just a white page, no error in the log no information at all.

我遇到过完全相同的症状,有些路由没有提供任何反馈,只是一个白页,日志中没有错误,没有任何信息。

Turns out, I was adding a new middleware, and I forgot to return $next($request)from my handle method. This was even more frustrating, because this middleware did not apply to every route, so I assumed that there was an intermittent error that was being thrown but not displayed on these routes.

原来,我正在添加一个新的中间件,但我忘了$next($request)从我的 handle 方法中返回。这更令人沮丧,因为这个中间件并不适用于每条路线,所以我假设有一个间歇性错误被抛出但没有显示在这些路线上。

回答by Vishnja

As Blair said, it may turn out that you put some wrong code in the middleware or in 'Exceptions/Handler.php' e.g. :

正如布莱尔所说,结果可能是你在中间件或“Exceptions/Handler.php”中放置了一些错误的代码,例如:

if($e->getStatusCode()===404) { ... }

if($e->getStatusCode()===404) { ... }

instead of

代替

if($e instanceof NotFoundHttpException) { ... }

if($e instanceof NotFoundHttpException) { ... }

回答by Svet

Even on Windows needs to do : chmod -R 777 storage/You can run it with Git Bash;

即使在 Windows 上也需要做:chmod -R 777 storage/你可以用 Git Bash 运行它;

回答by XanT

Also if you just installed lumen make sure you have renamed .env.exampleto .envin your main app directory as it won't work if your config is still named environment file is still named .env.example.

此外,如果你刚刚安装流明确保你已经改名.env.example.env你的主目录下的应用程序,因为它会如果你的配置仍命名为环境文件不工作仍在命名.env.example

回答by Fahad

I actually solved the problem by un-commentingthe line
Dotenv::load(__DIR__.'/../');in bootstrap/app.php.

其实我所解决的问题取消注释线
Dotenv::load(__DIR__.'/../');bootstrap/app.php

So that it actually loads it before compiling it and caching it ,
well running php artisan optimizedoes it for you , if you have Laravel (Not Lumen)

这样它就可以在编译和缓存之前实际加载它,如果你有 Laravel(不是 Lumen),
运行良好php artisan optimize就可以了

But if you look at their documentation it is commented out by default, i think they might have fixed it by now http://lumen.laravel.com/docs/installation.

但是如果你查看他们的文档,它默认被注释掉,我认为他们现在可能已经修复了http://lumen.laravel.com/docs/installation

回答by dbertels

Just for the sake of completeness, I had this issue when the error occurred in methods that used Model::findOrFail($someId). Replacing it with Model::find($someId)displayed the error log.

为了完整起见,当使用Model::findOrFail($someId). 用Model::find($someId)显示的错误日志替换它。

回答by Olpha Zarrouk

Go to config/app.phpand if it is like this :

转到config/app.php,如果它是这样的:

'debug' => env('APP_DEBUG', false),

'debug' => env('APP_DEBUG', false),

Then it change to :

然后它更改为:

'debug' => env('APP_DEBUG', true),

'debug' => env('APP_DEBUG', true),

this.

这个。

回答by Bhavin Thummar

I have faced same problem so i have checked handler.php file of exceptions folder where render function that have return value line is commented so page make blank.

我遇到了同样的问题,所以我检查了异常文件夹的 handler.php 文件,其中注释了具有返回值行的渲染函数,因此页面为空白。

public function render($request, Exception $exception)
{        
    //return parent::render($request, $exception);
}