Filter Sensitive Data from Whoops
The Whoops composer package comes as standard with the Laravel framework, but you can actually use it standalone in non-Laravel projects.
$whoops = new \Whoops\Run;
$whoops->prependHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
The above should only run in local/non-production environments.
However, if you are part of a team and you have some kind of error monitoring, you might want to filter out sensitive information such as your passwords.
Laravel has a nice way to do this, but to do it without the framework it's a bit harder to find out how to achieve it. After some digging, it is possible by adding something like:
$whoops->pushHandler(function($exception, $inspector, $run) {
isset($_POST['password']) ? $_POST['password'] = '👾 [FILTERED] 👾';
});
How you achieve this depends entirely on how your application is structured, but the best place is more than likely the same place that the composer require is used.
The whole example would look like:
$whoops = new \Whoops\Run;
$whoops->prependHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->pushHandler(function($exception, $inspector, $run) {
isset($_POST['password']) ? $_POST['password'] = '👾 [FILTERED] 👾';
});
$whoops->register();