PHP code example of temant-framework / temant-fault
1. Go to this page and download the library: Download temant-framework/temant-fault 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/ */
temant-framework / temant-fault example snippets
use TemantFramework\Fault\ExceptionHandler;
$handler = new ExceptionHandler();
$handler
->setDebug(true)
->setApplicationName('My App')
->setEditor('vscode')
->register();
// That's it. Any uncaught exception will now render a rich error page.
use TemantFramework\Fault\ExceptionHandler;
$handler = new ExceptionHandler();
$handler->setDebug(true)->register();
use TemantFramework\Fault\ContentType;
use TemantFramework\Fault\Renderer\RendererInterface;
use TemantFramework\Fault\ErrorContext;
$handler->setRenderer(ContentType::Json, new class implements RendererInterface {
public function render(ErrorContext $context, bool $debug = true): string
{
return json_encode(['error' => $context->message]);
}
public function contentType(): string
{
return 'application/json';
}
});