Svetoslav Dimitrov
Svetoslav Dimitrov

Reputation: 929

Laravel 5. Debug mode

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?

Upvotes: 8

Views: 71050

Answers (4)

Mohamed Allal
Mohamed Allal

Reputation: 21000

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:

enter image description here

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):

enter image description here

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

enter image description here

Laravel beautiful debug screen ❤️

Upvotes: 3

Darkcoder
Darkcoder

Reputation: 858

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

APP_ENV=production
APP_DEBUG=false

to

APP_ENV=local
APP_DEBUG=true

Upvotes: 0

Leoben Osamah
Leoben Osamah

Reputation: 11

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

Upvotes: 1

James
James

Reputation: 16359

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.

Upvotes: 16

Related Questions