1. Go to this page and download the library: Download contenir/contenir-errors 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/ */
contenir / contenir-errors example snippets
use Contenir\Errors\ErrorPage;
$page = new ErrorPage(404, 'Page not found', '<p>Try the homepage.</p>');
$page->status; // 404
$page->title; // 'Page not found'
$page->body; // '<p>Try the homepage.</p>'
$page->isEmpty(); // false; true only when title and body are both ''
use Contenir\Errors\ErrorPage;
use Contenir\Errors\Repository\FileRepository;
$repo = new FileRepository('/var/www/shared/config/autoload/errors.local.php');
$page = $repo->get(404);
if ($page !== null && ! $page->isEmpty()) {
// render $page->title and $page->body
}
$repo->save(new ErrorPage(404, 'Page not found', '<p>Try the homepage.</p>'));
$repo->delete(404);
return [
'errors' => [
'pages' => [
404 => [
'title' => 'Page not found',
'body' => '<p>Try the <a href="/">homepage</a>.</p>',
],
500 => [
'title' => 'Something went wrong',
'body' => '<p>We have been notified.</p>',
],
],
],
];
use Contenir\Errors\ErrorPage;
use Contenir\Errors\Repository\InMemoryRepository;
$repo = new InMemoryRepository([
new ErrorPage(404, 'Not found', '<p>Lost.</p>'),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.