beauty-exceptions plugin for Phalcon
  • PHP 47.9%
  • CSS 39.5%
  • JavaScript 12.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2013-04-23 17:30:20 +01:00
docs README 2013-01-05 19:09:38 -05:00
js Adding new theme, and setTheme option 2013-01-05 20:06:17 -05:00
Library/Phalcon/Utils Make sure to send the correct content type. 2013-04-23 17:30:20 +01:00
prettify Adding new theme, and setTheme option 2013-01-05 20:06:17 -05:00
themes escaping strings 2013-01-22 01:49:11 -05:00
loader.php escaping strings 2013-01-22 01:49:11 -05:00
README.md escaping strings 2013-01-22 01:49:11 -05:00

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);

//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