Reputation: 3409
I'm using Laravel 4.1 to write an application. For some reason I need to disable debug in all environments including production, but I need to provide a means for users to be able to enable debug mode without editing configuration files (app.php) whenever needed (that means at runtime)
Is there a way to do so? I tried to change debug settings in App::before but that does not seem to be the correct solution (exception handlers are already registered at that point)
Update:
In last paragraph I said
exception handlers are already registered at that point
This comment is misleading I think. Exception handlers should be registered anyway.
The actual problem I need to solve is: How to change which displayer (plainDisplayer or debugDisplayer) to use?
This decision is made at runtime (whenever an exception actually occures) based on value of a variable ($debug) in Illuminate\Exception\Handler
Calling app('exception')->setDebug(true)
makes exception handler to use debug displayer but I'm not sure if this is the correct way to do it, specially if I'm going to put this code in App::before filter
Upvotes: 1
Views: 3504
Reputation: 758
Why would you enable users to see your internal app debugging, that sounds like a security nightmare. Users would be able to force errors and potentially get sensitive information, such as API keys, database information, etc, etc.
Why not, throw/catch errors in your app, display a nice view to the user and log the actual errors somewhere away from the users view?
Upvotes: 1