PHP code example of samuelgfeller / slim-error-renderer
1. Go to this page and download the library: Download samuelgfeller/slim-error-renderer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
samuelgfeller / slim-error-renderer example snippets
$settings['error'] = [
// Must be set to false in production
'display_error_details' => false,
// Whether to log errors or not
'log_errors' => true,
];
use Slim\App;
return function (App $app) {
// ...
// Handle exceptions and display error page
$app->add(ExceptionHandlingMiddleware::class);
}
use SlimErrorRenderer\Middleware\NonFatalErrorHandlingMiddleware;
return [
// ...
NonFatalErrorHandlingMiddleware::class => function (ContainerInterface $container) {
$settings = $container->get('settings');
return new NonFatalErrorHandlingMiddleware(
$settings['error']['display_error_details'],
$settings['error']['log_errors'] ? $container->get(LoggerInterface::class) : null,
);
},
// ...
];
use Slim\App;
return function (App $app) {
// ...
// Promote warnings and notices to exceptions
$app->add(NonFatalErrorHandlingMiddleware::class); // <- Add here
// Handle exceptions and display error page
$app->add(ExceptionHandlingMiddleware::class);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.