Git Product home page Git Product logo

pretty-exceptions's Introduction

Pretty Exceptions

Pretty-Exceptions

Phalcon is a web framework delivered as a C extension providing high performance and lower resource consumption.

Pretty Exceptions is an utility to show exceptions/errors/warnings/notices using a nicely visualization.

This utility is not intended to be used in a production stage.

This utility catches uncatched exceptions, remember to remove any try/catch that avoid the utility can work.

The code in this repository is written in PHP.

Automatic Usage

The easiest way to use this utility is include its 'loader':

require '/path/to/pretty-exceptions/loader.php';

Manual include

Or you could include the utility manually or via an autoloader:

//Requiring the file
require '/path/to/pretty-exceptions/Library.php';

//Or using an autoloader
$loader = new Phalcon\Loader();

$loader->registerNamespaces(array(
        'Phalcon\\Utils' => '/path/to/pretty-exceptions/Library/Phalcon/Utils/'
));

$loader->register();

Usage

Listen for exceptions:

set_exception_handler(function($e)
{
	$p = new \Phalcon\Utils\PrettyExceptions();
	return $p->handle($e);
});

Listen for user errors/warnings/notices:

set_error_handler(function($errorCode, $errorMessage, $errorFile, $errorLine)
{
	$p = new \Phalcon\Utils\PrettyExceptions();
	return $p->handleError($errorCode, $errorMessage, $errorFile, $errorLine);
});

Options

The following is the way to configure the utility:

$p = new \Phalcon\Utils\PrettyExceptions();

//Change the base uri for static resources
$p->setBaseUri('/');

//Set if the backtrace must be shown
$p->showBacktrace(true);

//Set whether if open the user files and show its code
$p->showFiles(true);

//Set whether show the complete file or just the relevant fragment
$p->showFileFragment(true);

/**
 * Set whether show human readable dump of current Phalcon application instance
 *  Can optionally pass a Phalcon application instance as a prameter in the
 *  constructor, or as the last parameter of PrettyExceptions::handle() and
 *  PrettyExceptions::handleError()
 */
$p->showApplicationDump(true);

//Change the CSS theme (default, night or minimalist)
$p->setTheme('default');

//Handle the error/exception
//...

Live Demo

A live demo is available here and here

pretty-exceptions's People

Contributors

matthewbaggett avatar wyleilefflanator avatar kenjikobe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.