diff --git a/Core/ShopControl.php b/Core/ShopControl.php deleted file mode 100644 index 433d5eb..0000000 --- a/Core/ShopControl.php +++ /dev/null @@ -1,57 +0,0 @@ -isAdmin() && $this->getUser()) || !Registry::getConfig()->isProductiveMode() || $this->_isDebugMode()) { - $this->_run = new Run(); - $this->_run->pushHandler(new PrettyPageHandler()); - $this->_run->register(); - } - } - - /** - * Shows exception message if debug mode is enabled, redirects otherwise. - * - * @param oxConnectionException $oEx message to show on exit - */ - protected function _handleDbConnectionException($oEx) - { - $oEx->debugOut(); - if (($this->isAdmin() && $this->getUser()) || !Registry::getConfig()->isProductiveMode() || $this->_isDebugMode()) { - // let whoops do the fancy stuff :) - $this->_run->handleException($oEx); - } else { - header("HTTP/1.1 500 Internal Server Error"); - header("Location: offline.html"); - header("Connection: close"); - } - } -} diff --git a/README.md b/README.md index 90bab42..6e7b4ed 100755 --- a/README.md +++ b/README.md @@ -1,47 +1,32 @@ -smx_whoops -========== +Great module proudly presented by [OXID Hackathon 2017](https://openspacer.org/12-oxid-community/185-oxid-hackathon-nuernberg-2017/) ;-) -Integration of the [whoops](https://github.com/filp/whoops/) error handler base/framework for PHP into the [OXID](http://www.oxid-esales.com) eShop. +Module version for OXID eShop 6. Original module by [shoptimax GmbH](https://github.com/shoptimax/smx_whoops). ------ +# Features -![Whoops!](http://i.imgur.com/xiZ1tUU.png) +use [whoops - php errors for cool kids](https://github.com/filp/whoops) for exception and error handling -**whoops** is an error handler base/framework for PHP. Out-of-the-box, it provides a pretty -error interface that helps you debug your web projects, but at heart it's a simple yet -powerful stacked error handling system. +## Installation -## Installing -Here's a very simple way to install: +1. Composer +``` +composer require oxid-community/smxwhoops +``` -1. Download [whoops](https://github.com/filp/whoops/) OR use the provided "src" and "vendor" dirs (see 3.) from this repository. +2. functions.php -2. Use [Composer](http://getcomposer.org) to install Whoops: +Add the following lines in `modules/functions.php`: - Note: the proposed composer command for installing whoops didn't work for me: - - ```bash - composer require filp/whoops:1 - ``` - - So I had to add the composer lib to the composer.json file ("filp/whoops": "1.*") - see "composer_edited.json" - and do a +``` +define('__ROOT__', dirname(__FILE__, 2)); +require_once(__ROOT__ . '/modules/oxcom/smxwhoops/functions.php'); +``` - ```bash - php composer.phar install - ``` +# Screenshot - instead. - In the end, either of these should create the "src" and "vendor" dirs for you. - -3. Upload - modules - src - vendor - to your shop root. +![OXID_smxwhoops](https://camo.githubusercontent.com/31a4e1410e740fd0ccda128cbcab8723f45e7e73/687474703a2f2f692e696d6775722e636f6d2f305651706539362e706e67) -4. Activate the module in the shop backend. -## Authors +# Changelog -This whoops library was primarily developed by [Filipe Dobreira](https://github.com/filp), and is currently maintained by [Denis Sokolov](https://github.com/denis-sokolov). A lot of awesome fixes and enhancements were also sent in by [various contributors](https://github.com/filp/whoops/contributors). -The smx_whoops module for integrating whoops into OXID was developed by shoptimax GmbH, Gernot Payer and Stefan Moises. +* 2017-12-18 2.0.0 module release diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..130126c --- /dev/null +++ b/functions.php @@ -0,0 +1,28 @@ +silenceErrorsInPaths('@' . VENDOR_PATH . '@', E_WARNING | E_DEPRECATED); +$whoops->silenceErrorsInPaths('@' . INSTALLATION_ROOT_PATH . '/source/tmp/@', E_WARNING); +$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); +$whoops->register(); diff --git a/metadata.php b/metadata.php index 0137b1b..b31eb53 100755 --- a/metadata.php +++ b/metadata.php @@ -1,12 +1,12 @@ / OXID Community - * @link https://github.com/OXIDprojects/adminsearch - * @see https://github.com/OXIDCookbook/ocb_cleartmp + * @license MIT License http://opensource.org/licenses/MIT + * @author shoptimax GmbH / OXID Community + * @link https://github.com/OXIDprojects/smx_whoops + * @see https://github.com/shoptimax/smx_whoops */ /** @@ -19,15 +19,14 @@ */ $aModule = [ 'id' => 'smx_whoops', - 'title' => 'OXID Community Whoops (by shoptimax)', + 'title' => 'OXID Community Whoops Exception Handler (by shoptimax)', 'description' => 'Whoops exception handling', 'thumbnail' => '', 'version' => '2.0.0', 'author' => 'OXID Community', - 'url' => 'https://github.com/OXIDCookbook/smx_whoops', + 'url' => 'https://github.com/OXIDprojects/smx_whoops', 'email' => '', 'extend' => [ - \OxidEsales\Eshop\Core\ShopControl::class => \OxidCommunity\Whoops\Core\ShopControl::class, ], 'settings' => [ ], diff --git a/smx_whoops_oxshopcontrol.php b/smx_whoops_oxshopcontrol.php deleted file mode 100755 index d89ba97..0000000 --- a/smx_whoops_oxshopcontrol.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @author: Stefan Moises - * @version: 1.0.1 - */ - -class smx_whoops_oxshopcontrol extends smx_whoops_oxshopcontrol_parent -{ - /** - * @var Whoops\Run Whoops run object - */ - protected $_run = null; - - /** - * Sets default exception handler. - * Ideally all exceptions should be handled with try catch and default exception should never be reached. - * - * @return null; - */ - protected function _setDefaultExceptionHandler() - { - if ( ($this->isAdmin() && $this->getUser()) || !oxRegistry::getConfig()->isProductiveMode() || $this->_isDebugMode() ) { - // load Whoops - require getShopBasePath() . 'vendor/autoload.php'; - - $this->_run = new Whoops\Run(); - $this->_run->pushHandler(new Whoops\Handler\PrettyPageHandler()); - $this->_run->register(); - } - } - - /** - * Shows exception message if debug mode is enabled, redirects otherwise. - * - * @param oxConnectionException $oEx message to show on exit - */ - protected function _handleDbConnectionException( $oEx ) - { - $oEx->debugOut(); - if ( ($this->isAdmin() && $this->getUser()) || !oxRegistry::getConfig()->isProductiveMode() || $this->_isDebugMode() ) { - // let whoops do the fancy stuff :) - $this->_run->handleException( $oEx ); - } else { - header( "HTTP/1.1 500 Internal Server Error"); - header( "Location: offline.html"); - header( "Connection: close"); - } - } -} - \ No newline at end of file