renakdup / whoops-wordpress-error-handler
Whoops PHP Error handler for WordPress.
Package info
github.com/renakdup/whoops-wordpress-error-handler
pkg:composer/renakdup/whoops-wordpress-error-handler
Requires
- php: >=7.3.0
- filp/whoops: ^2.15
Requires (Dev)
- ergebnis/composer-normalize: ^2.42
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Whoops PHP error handler for WordPress with different themes.
It catches fatal errors and exceptions and shows in beautiful format.
We can see a stack trace, go through the stack trace to see the called parts in the code.
In the debug information we can find GET, POST, Files, Cookie, Session, Server/Request Data, Environment Variables.
How to install WordPress error handler
-
Require via Composer
composer require renakdup/whoops-wordpress-error-handler
Or if you want to use it just for local environment
composer require renakdup/whoops-wordpress-error-handler --dev
-
Create a file of mu-plugin by the address
wp-content/mu-plugins/mu-plugins/whoops-error-handler.php:mkdir wp-content/mu-plugins touch wp-content/mu-plugins/whoops-error-handler.php
-
Add the calling code to the file
<?php // This checks necessary if you use the package as a dev dependency if ( ! class_exists( Renakdup\WhoopsErrorHandler\ErrorHandler::class ) ) { return; } $error_handler = new Renakdup\WhoopsErrorHandler\ErrorHandler(); $error_handler->init();
That's it!
How to configure
Showing conditionals
By the default error handler isn't displayed for wp_get_environment_type() === 'production'.
If you want to exclude additional envs, you should use the filter:
add_filter( 'renakdup/whoops-error-handler/prohibited-envs', function ( $defaults ) { return array_merge( $defaults, [ 'staging', 'development' ] ); }, 10, 1);
If you want to disable error handler for some special conditionals then use this filer:
add_filter( 'renakdup/whoops-error-handler/not-enable', function ( $default ) { if ( ! WP_DEBUG || ! WP_DEBUG_DISPLAY ) { return true; } }, 10, 1);
Themes
To use one of the available themes, you can pass theme's name while instantiating object.
$error_handler = Renakdup\WhoopsErrorHandler\WhoopsErrorHandler( 'gray' );
Available themes
Smooth material dark
$name = 'material-dark-smooth';
Material dark
$name = 'material-dark';
Gray
$name = 'gray';
Original optimized
$name = 'original-optimized';
Original Default
$name = 'default-original';




