Skip to content
JosephLenton edited this page Jun 28, 2012 · 9 revisions

These are a number of different example on how you can setup and run PHP Error. They aren't the only way, but you can just copy and paste if you want to get going quickly.

The current version of PHP-Error can be found here.

In all cases, 'display_errors' must be set to 'On' for PHP Error to work. This is a safety feature.

Run in a single project

  • Place php_error.php into your project
  • At the entry point of your site add ...
    require('php_error.php');
    \php_error\reportErrors();

I want it outside my project, but running on all dev sites

  • Place php_error.php somewhere on your PC, for example: C:\php\php_error.php
  • open your php.ini file
  • find 'auto_prepend_file'
  • set it to auto prepend php_error.php
  • add the option 'php_error.autorun = On'
    auto_prepend_file = "C:\php\php_error.php"
    php_error.autorun = On

I want it outside my project, but only run on selected projects

  • Place php_error.php somewhere on your PC, for example: C:\php\php_error.php
  • open your php.ini file
  • find 'auto_prepend_file'
  • add 'php_error.php' to this file
    auto_prepend_file = "C:\php\php_error.php"
  • find the entry point to your project
  • run 'reportErrors' if php_error is loaded (so in production this silently fails)
    if ( function_exists('\php_error\reportErrors') ) {
        \php_error\reportErrors();
    }

Disable it globally in production

But you can forcefully shut it down globally by:

  • open php.ini on your production server
  • add the option 'php_error.force_disabled = On'
    php_error.force_disabled = On

Alternatively:

    display_errors = Off

Either of these will cause PHP Error to silently do nothing.

Clone this wiki locally