Configure PHP Lumen 5 HTTP Exception Handlers with common JSON responses.
Copy (replace) only the attached files to their respective directories. app/Exceptions/Handler.php
and app/Http/Middleware/Authenticate.php
Tip: Via your .env
file you can handle the visibility of the HTTP Exception responses. APP_DEBUG=false
(for display json exception responses in production)
Note for those using this code, I recommend replacing
env('APP_DEBUG')
withconfig('app.debug')
as that will be more compatible with Laravel's environment caching. I've encountered issues in the past withenv()
not updating or returning null on some server setups after deployment.