PHP code example of radweb / json-exception-formatter
1. Go to this page and download the library: Download radweb/json-exception-formatter 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/ */
radweb / json-exception-formatter example snippets
use Radweb\JsonExceptionFormatter\FormatterInterface;
class CustomDebugFormatter implements FormatterInterface {
public function formatDebug(Exception $e)
{
return array(
'theError' => array(
'message' => $e->getMessage(),
'detail' => 'In file '.$e->getFile().' on line '.$e->getLine(),
),
);
}
public function formatPlain(Exception $e)
{
return array(
'theError' => array(
'message' => $e->getMessage(),
// we don't want to display debug details in production
),
);
}
}