PHP Error, error reporting done right!
Better error messages, full syntax highlighting, code snippets,
and works for ajax too
Download
GitHub
<?php
// place at start of site
require( 'php_error.php' );
\php_error\reportErrors();
// place at start of site
require( 'php_error.php' );
\php_error\reportErrors();
Examples
Here you can find more example setups, to make getting started as easy as possible.
API
Documentation for the API can be found here, and you can find information on the php.ini settings available here.
Customization
Options can be given when reporting errors, allowing error reporting to be customized, and to help give better context in regards to your application.
An Example Stack Trace
This is an example of the actual HTML displayed when an error is reported
phperror.localhost | /example/www
AJAX PAUSED phperror.localhost/
View not found: home/indexx
6 app/controller/home.php
<?
class Home extends SiteController
{
public function index() {
$this->frame->postHTML('css', css( '/css/stack_trace.css' ) );
$this->view->home->indexx();
$this->frame->html('js', js( '/js/jquery.1.7.2.js' ) . js( '/js/stack_trace.js' ) );
}
}
}
} else {
if ( is_array($file) ) {
$file = join( $file, '/' );
}
$filePath = $this->getFlexi()->findFrom( 'view', $file );
if ( $filePath === false ) {
throw new Exception( 'View not found: ' . $file );
} else {
require( $filePath );
}
* @param useFrame states if the frame for this controller should be run or not, before loading the view, and defaults to true.
*/
public function __view( $file, &$params, $useFrame=true )
{
if ( !$this->isInsideView && $useFrame && $this->frame != null ) {
$this->frame->_loseDefault();
$this->frame->_runTo();
}
$this->__viewInner( $file, $params );
}
$params = func_num_args() > 1 ?
array_slice( func_get_args(), 1 ) :
null ;
return $this->__view( $file, $params );
}
function __view( $file, &$params )
{
$this->parentController->__view( $file, $params );
return $this;
}
} else {
$this->viewParts = array( $parts, $prop );
}
return $this;
}
function __call( $view, $params )
{
return $this->__view( $this->buildViewPath($view), $params );
}
function __invoke( $params ) {
$num = $method->getNumberOfRequiredParameters();
while ( count($params) < $num ) {
$params[]= null;
}
$this->setPageID( strtolower($class), strtolower($methodName) );
$this->events->runPreAction( $controller, $params, $class, $methodName );
$result = $method->invokeArgs( $controller, $params );
$this->events->runPostAction( $controller, $result, $class, $methodName );
return true;
}
if (
! $this->tryControllerMethod(
$controller,
$name,
$action,
$params,
$methodObj
)
) {
Flexi::popFlexi();
throw new Exception(
$controllerPath = $this->findController( $name );
if ( $controllerPath === false ) {
if ( $isDefault ) {
throw new Exception( 'default controller not found: ' . $this->defaultController );
} else {
return $this->run404();
}
} else {
return $this->loadAndRunController( $controllerPath, $name, $action, $params, true );
}
}
}
}
}
// check name is not for this script
if ( ($this->rootURI.$name) == $_SERVER['PHP_SELF'] ) {
$name = null;
}
$this->runInner( $name, $function, $params );
}
}
// stop scripts from auto-exiting
define( 'ACCESS_OK', true );
require( 'flexi/flexi.php' );
$flexi = new Flexi();
$flexi->loadConfig( 'config.php' );
$flexi->loadConfig( 'config_local.php', true );
$flexi->loadConfig( 'frames.php' );
// run the website!
$flexi->run( $_SERVER['REQUEST_URI'] );
$flexi->events()->runOnEnd();
121 | flexi/core/corecontroller.php | throw new Exception( 'View not found: ' . $file ); |
84 | flexi/core/corecontroller.php | CoreController->__viewInner( ["home", "indexx"], [] ) |
236 | flexi/core/loader.php | CoreController->__view( ["home", "indexx"], [] ) |
371 | flexi/core/loader.php | FlexiViewLoader->__view( ["home", "indexx"], [] ) |
6 | app/controller/home.php | FlexiViewLoader->__call( "indexx", [] ) |
6 | app/controller/home.php | FlexiViewLoader->indexx() |
[Internal PHP] | Home->index() | |
1230 | flexi/flexi.php | ReflectionMethod->invokeArgs( $Home, [] ) |
1174 | flexi/flexi.php | Flexi->tryControllerMethod( $Home, "home", "index", [], $ReflectionMethod ) |
1096 | flexi/flexi.php | Flexi->loadAndRunController( "/example/www", "home", "index", [], true ) |
993 | flexi/flexi.php | Flexi->runInner( NULL, NULL, [] ) |
12 | index.php | Flexi->run( "/" ) |
General project information provided in one place
Code provided from each layer in the stack
Fully syntax highlighted stack trace
Files highlighted according to context