Skip to content
JosephLenton edited this page Mar 24, 2013 · 10 revisions

The options can be passed into 'reportErrors' when it is called. They are stored in an associative array of 'option' mapping to the value.

Usage Examples

Options can be passed in when calling 'reportErrors'.

    // create an array of 'options', and pass them into report errors
    $options = array();
    \php_error\reportErrors( $options );
    // a range of example options set
    // and then passed in when turning on reporting errors
    $options = array(
            'snippet_num_lines' => 10,
            'background_text'  => 'Error!',
            'error_reporting_off' => 0,
            'error_reporting_on' => E_ALL | E_STRICT
    );
    \php_error\reportErrors( $options );

If you chose to create the ErrorHandler manually (see API section), then you can pass in the same options to it's constructor.

    $options = array(
            // options set here
    );
    $handler = new \php_error\ErrorHandler( $options );
    $handler->turnOn();

All Options

Option Default Description
catch_ajax_errors true When on, this will inject JS Ajax wrapping code, to allow this to catch any future JSON errors.
catch_supressed_errors false The @ supresses errors. If set to true, then they are still reported anyway, but respected when false.
catch_class_not_found true When true, loading a class that does not exist will be caught. If there are any existing class loaders, they will be run first, giving you a chance to load the class.
error_reporting_on -1 (everything) The error reporting value for when errors are turned on by PHP Error.
error_reporting_off the value of 'error_reporting' The error reporting value for when PHP Error reporting is turned off. By default it just goes back to the standard level.
application_root $_SERVER['DOCUMENT_ROOT'] When it's working out hte stack trace, this is the root folder of the application, to use as it's base. A relative path can be given, but lets be honest, an explicit path is the way to guarantee that you will get the path you want. My relative might not be the same as your relative.
display_line_numbers true When on, line numbers are shown in the editor, and when off, they are not.
server_name $_SERVER['SERVER_NAME'] The name for this server; it's domain address or ip being used to access it. This is displayed in the output to tell you which project the error is being reported in.
ignore_folders null (no folders) This is allows you to highlight non-framework code in a stack trace. An array of folders to ignore, when working out the stack trace. This is folder prefixes in relation to the application_root, whatever that might be. They are only ignored if there is a file found outside of them. If you still don't get what this does, don't worry, it's here cos I use it.
application_folders null (no folders) Just like ignore, but anything found in these folders takes precedence over anything else.
background_text an empty string The text that appeares in the background. By default this is blank. Why? You can replace this with the name of your framework, for extra customization spice.
wordpress false This is no longer needed on the latest versions of WordPress.

When on, this will use a lower error reporting level, which works with Wordpress. This is because the Wordpress code base is full of minor bugs, and doesn't like strict error reporting.
enable_saving true When true, PHP Errors allows external requests to save files. This is so the editor can save changes back.
save_url $_SERVER['REQUEST_URI'] When PHP Error goes to save changes, it doesn't know where to send the request. So by default, it sends it to whatever page made the error, and then quits.
        This option allows you to specify a dedicated url to be used
        instead.
    </td>
</tr>

php.ini - changing the defaults

The default values for the options can be set in your php.ini file. See the php.ini section for more information.

Query Parameter options

Options can be passed to PHP Error via a query parameter. This is useful for ajaxy-like code, which isn't actually ajax, such as using an iframe for performing ajax.

They can be used as either a POST or GET parameter, such as:

    www.example.com?php_error_is_ajax=true
Option Description
php_error_is_ajax Tells PHP Error that the request should be treated as though it is ajax.
        It can already identify straight forward ajax calls, but this is useful for
        when you are trying ajax calls manually in the browser (i.e. not via JS),
        or when they are built from components such as iframes.
    </td>
</tr>
Clone this wiki locally