Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 843
Svetoslav Dimitrov Avatar asked Nov 19 '16 09:11

Svetoslav Dimitrov


People also ask

How do I enable debug mode in Laravel?

Enable or disable debug mode using app. Open the app. php file located in your config/app. php laravel project. Search for debug key and change true to enable debug mode and false for disabling debug mode default it will show false.

How do I debug a Laravel project?

The Debugbar will start working inmediately if the debug mode is turned on: To do it so, you just need to modify in your config/app. php or . env file the debug_mode to true. If you wish to use the dump methods in the debugbar console, you need to include the alias to your /config/app.

How do I enable errors in Laravel?

Through your config/app. php , set 'debug' => env('APP_DEBUG', false), to true . Or in a better way, check out your . env file and make sure to set the debug element to true.


2 Answers

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.

like image 159
James Avatar answered Sep 29 '22 08:09

James


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 ❤️

like image 41
Mohamed Allal Avatar answered Sep 29 '22 08:09

Mohamed Allal