Unfortunately I’m still not able to write thousands of lines without making a mistake, I’m still trying of course! In most situations you’ll get enough information from PHP to fix the problem quickly but sometimes you have to navigate through a bunch of files until you’ve found the origin of the problem.
This can be annoying and time consuming.
Luckily Joseph Lenton wrote a rather nice tool which shows you more information and it’s also very easy to use. There’s no PHP module involved, no installed required like XDebug.
Get the source of php_error.php from this page: https://github.com/JosephLenton/PHP-Error.
After that all you need to do is to include this at the top of the first file you’re working with:
require( 'php_error.php' ); \php_error\reportErrors();
After that, you’ll see a nice output like this if you make a mistake:
It might happen that you’re getting a bunch of stuff which you don’t care about. That’s probably because you have some warning or notices about deprecated functions. You can either fix them or if you’re lazy, change the error_reporting like this:
require( 'php_error.php' ); $options = array( 'snippet_num_lines' => 10, 'error_reporting_off' => 0, 'error_reporting_on' => E_ERROR | E_WARNING | E_PARSE ); \php_error\reportErrors( $options );
You can find more options here: https://github.com/JosephLenton/PHP-Error/wiki/Options.