Laravel 5 - env local debug true no errors shown
Asked Answered
D

13

35

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

php artisan env

I get this

Current application environment: local

The debug config for my local env is set to true

return [

    'debug' => true,

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

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

What am I missing?

Demigod answered 28/11, 2014 at 15:56 Comment(0)
S
80

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.

Speculator answered 21/1, 2015 at 9:37 Comment(2)
For the record, setting 777 permissions is really dangerous even if you are in a development environment. Avoid unless you know what you're doing.Chromous
do not do this a production server, just set /storage to be available to ApachePotpie
C
15

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

I had the same problem and the artisan command did the trick.

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:

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.

Cardinalate answered 28/11, 2014 at 16:14 Comment(2)
Thanks for the hint, I found that the problem was in the permissions to the storage folder. It's weird because the log file (inside the storage folder) was correctly created, and correctly updated - no permission errors for this file? - so I just chmod -R 777 on storage folder and now I can see the errors. I didn't run the php artisan optimize because I just updated composer (that in the end does the same thing as the command above) and I was looking at the folder you mentioned and I actually don't have that folder (that's why I thought about permissions issue). ThanksDemigod
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, 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).Cardinalate
P
3

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.

Padauk answered 2/4, 2015 at 0:36 Comment(0)
B
3

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

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

instead of

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

Bans answered 22/9, 2015 at 10:17 Comment(0)
B
1

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

Bramante answered 5/12, 2016 at 14:58 Comment(0)
M
1

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

Metonym answered 14/2, 2017 at 2:11 Comment(0)
H
1

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

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

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.

Hauck answered 14/3, 2017 at 9:57 Comment(0)
T
1

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.

Thant answered 2/2, 2018 at 1:21 Comment(0)
M
0

If the above answers didn't work for you, you may want to check the config files that you might have changed and start debugging from there.

In my case, the above solutions didn't work for me because the root cause of my problem was changing the timezone in config/app.php file (from laravel default UTC I changed it to EST5EDT). For some reason the timezone setting change prevents laravel from logging the errors in storage folder and I am getting blank screen (no whoops! error message). I changed the timezone to America/New_York instead and the error logs are working again.

Hope this helps.

Measles answered 7/4, 2015 at 16:49 Comment(0)
T
0

For me what worked perfectly was disabling hhvm in the Homestead.yaml file, then I did vagrant reload --provision and that was it!

Tactic answered 14/7, 2016 at 21:14 Comment(0)
S
0

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

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

Then it change to :

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

this.

Solanaceous answered 14/2, 2018 at 12:9 Comment(1)
This solution change default value, not the reading of ENV file.Discount
C
0

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.

public function render($request, Exception $exception)
{        
    //return parent::render($request, $exception);
}
Calica answered 13/7, 2018 at 11:52 Comment(0)
B
0

Please check in .env file

APP_ENV=local

APP_DEBUG=true

and also in config/app.php, check for these values

'env' => env('APP_ENV', 'local'),

'debug' => true,
Brinkley answered 6/9, 2022 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.