Subscribe to PHP Freaks RSS

Rob Allen: Displaying errors in Expressive with Twig

syndicated from www.phpdeveloper.org on October 19, 2017

Rob Allen has a quick post for the Twig and Zend Expressive users out there showing how to display errors if you're not using the Whoops error handler.

If you're not using the Whoops error handler with Expressive and are using the Twig renderer, then you are given no information about the problem that occurred, even in debug mode.

He includes the Twig template to output the error message and, if the application is in "debug" mode, show an optional block of extra information. This provides details about the exception thrown and some of the previous errors. The previous errors are looped about output to provide more context around the failure.