6
6
[ ![ Total Downloads] ( https://img.shields.io/packagist/dt/samuelgfeller/slim-error-renderer.svg )] ( https://packagist.org/packages/samuelgfeller/slim-error-renderer/stats )
7
7
8
8
This package provides an alternative to the default Slim error handler and renderer.
9
- It renders a styled [ error details page] ( #error-details-design ) with the stack trace and the error message
10
- or a [ generic error page] ( #generic-error-page-design ) for production.
9
+ It renders a styled error details page with the stack trace and the error message
10
+ or a generic error page for production.
11
11
12
12
Custom error page renderers can be created to change the design of the error pages
13
13
by implementing the ` ErrorDetailsPageRendererInterface `
@@ -17,26 +17,11 @@ It also provides a [middleware](#exception-heavy-middleware) to make the project
17
17
which means that it will throw exceptions with a stack trace for notices and warnings during
18
18
development and testing like other frameworks such as Laravel or Symfony.
19
19
20
- ## Why use this package?
21
-
22
- A reason this small library exists instead of using the default Slim error handler and a [ custom
23
- error renderer] ( https://www.slimframework.com/docs/v4/middleware/error-handling.html#error-handlingrendering ) ,
24
- is to provide the "exception-heavy" feature and better-looking error pages.
25
- But these things can be achieved with a custom error renderer and middleware located in the project as well.
20
+ ## Preview
26
21
27
- The issue with the default ` Slim\Handlers\ErrorHandler ` is that while testing, the
28
- ` $contentType ` in the error handler is ` null ` and instead of using any custom error renderer
29
- its hardcoded to use the ` Slim\Error\Renderers\HtmlErrorRenderer ` . This has two consequences:
30
-
31
- 1 . The error is not thrown while integration testing, which means debugging is harder.
32
- 2 . Tests where an exception is expected, fail with the
33
- [ PHPUnit 11 warning] ( tps://github.com/sebastianbergmann/phpunit/pull/5619 )
34
- ` Test code or tested code did not remove its own error handlers ` .
35
- A fix for this message is calling ` restore_error_handler() ` but this can't be done as the error handler doesn't
36
- allow for custom error renderers when testing.
37
-
38
- So a custom handler is required anyway, and with the custom renderers and the handling of
39
- non-fatal errors, it made sense to put that in a separate small library.
22
+ | Exception | Warning and Notice | Generic error page |
23
+ | -----------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------------------|
24
+ | <img src =" https://github.com/samuelgfeller/slim-error-renderer/assets/31797204/ef88013f-841f-417b-8626-6c1fc4d38a8b " > | <img src =" https://github.com/samuelgfeller/slim-example-project/assets/31797204/9c2e3d7c-6752-4854-b535-5e54d25fd11e " > | <img src =" https://github.com/samuelgfeller/slim-example-project/assets/31797204/d1fd052e-a16f-4a76-895a-2eac456c4a79 " > |
40
25
41
26
## Requirements
42
27
@@ -55,11 +40,14 @@ composer require samuelgfeller/slim-error-renderer
55
40
```
56
41
57
42
### Configuration
43
+
58
44
The following configuration values are required in the settings.
59
- [ Modify accordingly] ( https://github.com/samuelgfeller/slim-example-project/wiki/Error-Handling#application-configuration )
60
- in the development, production, and testing configuration files.
45
+ Modify accordingly
46
+ in the development, production, and testing
47
+ [ configuration files] ( https://github.com/samuelgfeller/slim-example-project/wiki/Error-Handling#application-configuration ) .
61
48
62
49
File: ` config/defaults.php `
50
+
63
51
``` php
64
52
$settings['error'] = [
65
53
// Must be set to false in production
@@ -206,16 +194,23 @@ implementation of this package and the
206
194
[ ` slim-example-project ` ] ( https://github.com/samuelgfeller/slim-example-project ) for a custom
207
195
generic error page rendering with layout.
208
196
209
- ## Error details design
210
-
211
- ### Fatal error
212
-
213
- <img src =" https://github.com/samuelgfeller/slim-example-project/assets/31797204/fea0abee-17f6-46dd-9efa-c5928244f7b6 " width =" 600 " >
197
+ ## Why use this package?
214
198
215
- ### Warning / Notice
199
+ A reason this small library exists instead of using the default Slim error handler and a [ custom
200
+ error renderer] ( https://www.slimframework.com/docs/v4/middleware/error-handling.html#error-handlingrendering ) ,
201
+ is to provide the "exception-heavy" feature and better-looking error pages.
202
+ But these things can be achieved with a custom error renderer and middleware located in the project as well.
216
203
217
- <img src =" https://github.com/samuelgfeller/slim-example-project/assets/31797204/9c2e3d7c-6752-4854-b535-5e54d25fd11e " width =" 600 " >
204
+ The issue with the default ` Slim\Handlers\ErrorHandler ` is that while testing, the
205
+ ` $contentType ` in the error handler is ` null ` and instead of using any custom error renderer
206
+ its hardcoded to use the ` Slim\Error\Renderers\HtmlErrorRenderer ` . This has two consequences:
218
207
219
- ## Generic error page design
208
+ 1 . The error is not thrown while integration testing, which means debugging is harder.
209
+ 2 . Tests where an exception is expected, fail with the
210
+ [ PHPUnit 11 warning] ( tps://github.com/sebastianbergmann/phpunit/pull/5619 )
211
+ ` Test code or tested code did not remove its own error handlers ` .
212
+ A fix for this message is calling ` restore_error_handler() ` but this can't be done as the error handler doesn't
213
+ allow for custom error renderers when testing.
220
214
221
- <img src =" https://github.com/samuelgfeller/slim-example-project/assets/31797204/d1fd052e-a16f-4a76-895a-2eac456c4a79 " width =" 600 " >
215
+ So a custom handler is required anyway, and with the custom renderers and the handling of
216
+ non-fatal errors, it made sense to put that in a separate small library.
0 commit comments