Thanks! I will be looking into these. I like the samsonasik’s approach of using the database to record errors.
But as far as error handling, I do have Whoops error handler installed, and for whatever reason it does not trigger.
It does trigger on some errors, but not some others. It did not trigger on this one and I do not have much clue as to why.
Recreating Error
The error I had was me trying to use a parameter in a layout when that parameter was not defined. To recreate:
- In
layout::default
use a parameter like echo $this->randomObject->getName()
What I see on screen is partial layout rendered, and nothing else. Layout quits being rendered when it encounters getName()
being called on parameter randomObject
, as that object was not defined. My Whoops is not triggered. No error is recorded.
I should note that $this->randomObject
, despite its random name, is seen as type Zend\View\Renderer\PhpRenderer
in the view. Because in my case, I use ZendViewRendererFactory
for my TemplateRendererInterface
, so I am guessing that view sees it as a TemplateRendererInterface
instance and tries to call getName()
method on that instance.
But Whoops is not picking it up. So I am concerned about whether the other approaches will. I will give them a try.
Whoops does not catch the error
My Whoops set up is like so:
//development.local.php
return [
'dependencies' => [
'factories' => [
ErrorResponseGenerator::class => Container\WhoopsErrorResponseGeneratorFactory::class,
'Zend\Expressive\Whoops' => Container\WhoopsFactory::class,
'Zend\Expressive\WhoopsPageHandler' => Container\WhoopsPageHandlerFactory::class
],
],
'whoops' => [
'json_exceptions' => [
'display' => true,
'show_trace' => true,
'ajax_only' => true,
],
],
];