portrino/typo3-whoops

Whoops error/ exception handler for TYPO3 projects

0.1.0 2017-11-13 19:33 UTC

This package is auto-updated.

Last update: 2021-05-19 19:12:43 UTC


README

Build Status Latest Stable Version Total Downloads

Use the whoops error/ exception handler instead of the default DebugExceptionHandler shipped within the TYPO3 core. This supports you with a nicer exception handling output in the frontend or on cli during extension development. Should only be used in a (local) development context!

Getting started

Install using composer

$ composer require --dev portrino/typo3-whoops

Activation

via AdditionalConfiguration.php

Add the following lines into your typo3conf/AdditionalConfiguration.php:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = 
    \Portrino\Typo3Whoops\Error\WhoopsExceptionHandler::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = 
    \Portrino\Typo3Whoops\Error\WhoopsExceptionHandler::class;

We highly recommend to use a context related condition around it. For example:

$applicationContext = \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext()->__toString();
if (strpos($applicationContext, 'Development') !== false) {

    $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = 
        \Portrino\Typo3Whoops\Error\WhoopsExceptionHandler::class;
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = 
        \Portrino\Typo3Whoops\Error\WhoopsExceptionHandler::class;
        
}
Compatibility for PHP versions < 7

Because the ExceptionHandlerInterface under php5.5 and 5.6 differs from the one from php > 7 we provide you a compatible version of the WhoopsExceptionHandler.

$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = 
    \Portrino\Typo3Whoops\Compatibility\Error\WhoopsExceptionHandler::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = 
    \Portrino\Typo3Whoops\Compatibility\Error\WhoopsExceptionHandler::class;

via TYPO3 Console

typo3cms configuration:set --path SYS/debugExceptionHandler --value "Portrino\\Typo3Whoops\\Error\\WhoopsExceptionHandler"
typo3cms configuration:set --path SYS/productionExceptionHandler --value "Portrino\\Typo3Whoops\\Error\\WhoopsExceptionHandler"

Usage

Now trigger an exception somewhere in your extension code and you should see php errors for cool kids.

Whoops!

Authors

  • Axel Böswetter - Initial work - EvilBMP
  • André Wuttig - Bugfixes, Unit Tests, Acceptance Tests, Travis CI Integration - aWuttig

See also the list of contributors who participated in this project.