Laravel 5. Debug mode

家住魔仙堡 提交于 2020-07-29 06:12:46

问题


I set debug mode to true in config->app and deployed it on the server:

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

I have following code in Controller to check the mode:

...
$debug = config('app.debug');
var_dump($debug);
$product->save();

Result on local machine:

C:\xampp\htdocs\MK\app\Http\Controllers\ProductController.php:45:boolean true

Result on the server:

bool(false) Whoops, looks like something went wrong.

Why isn't debug mode set on server side?


回答1:


This line in your config file, 'debug' => env('APP_DEBUG', true), may be the cause of your issue.

It is saying; set debug to the value defined in my .env file, and if there is none then use true.

As such it is looking at APP_DEBUG=false in your .env file, even though you have set the second parameter to true.

Try updating the setting in your .env file to true.




回答2:


In your case, just go to your .env file and change "APP_DEBUG=false" to "APP_DEBUG=true"




回答3:


You can also change the setting into your .env file from

APP_ENV=production
APP_DEBUG=false

to

APP_ENV=local
APP_DEBUG=true



回答4:


First of all the debug mode need to be activated! And the APP_ENV need to be set to local.

Now how to do that! We need to check in multiple places

.env file

APP_ENV=local
APP_DEBUG=true

Make sure they are not set twice! You can Uncomment with # APP_ENV=production (using #).

Too importantly you need to change APP_ENV to local.

And to check, you can run

php artisan env

You get something like:

config/app.php

Next thing to check is config/app.php

Know that the .env is processed by this file! And that file is where the config is managed!

Check that the config line is not removed or commented!
(depending if it's a new install or some already worked on project)

Depending on what version of Laravel you are using! It may be slightly different!

But the point is to make sure that the .env config is loaded or it will default to true!

'debug' => env('APP_DEBUG', true) // second param the default value

In our current project! The setting were as bellow:

'debug' => (function_exists('env')) ? env('APP_DEBUG', true) : true,

it check if env exists! if yes it use it ! If not it will set the default value directly!

My teammate! Didn't notice that! And he got an error! Becaues somebody before us have changed it as bellow (and was commented):

The image is added to illustrate how a mistake can be made! Also for navigation clearance!

Bottom line check it out and make sure it's all right! (if all right then just move to the next section)

Ok all set but not working

Yea to be expected !

Clear views and cache

Importantly you should know that you may need to clear the cache

Run

php artisan view:clear

and

php artisan cache:clear

After that it should work!

If not!

Files permissions

You may have file system permission problems!

Check this out

https://stackoverflow.com/a/28063794/7668448

The expected debug view

Laravel beautiful debug screen ❤️



来源:https://stackoverflow.com/questions/40691240/laravel-5-debug-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!