1. Go to this page and download the library: Download contenir/errors-mezzio 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 / errors-mezzio example snippets
// config/config.php
$aggregator = new ConfigAggregator([
\Contenir\Errors\Mezzio\ConfigProvider::class,
// ...
]);
// config/pipeline.php
use Contenir\Errors\Mezzio\ErrorPageMiddleware;
use Laminas\Stratigility\Middleware\ErrorHandler;
use Mezzio\Handler\NotFoundHandler;
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
$app->pipe(ErrorPageMiddleware::class);
$app->pipe(ErrorHandler::class);
// ... routing, dispatch ...
$app->pipe(NotFoundHandler::class);
};
// config/autoload/errors.global.php
return [
'errors' => [
'view_template' => 'contenir-errors::fault', // override to use a Site-owned template
'layout' => null, // null = renderer default, false = no layout
'logger' => 'log.psr3', // optional PSR-3 service name
'debug' => false, // true = leave error responses alone
'file' => getcwd() . '/config/autoload/errors.local.php',
],
];
return [
'errors' => [
'pages' => [
404 => ['title' => 'Not Found', 'body' => 'The page is missing or outdated.'],
500 => ['title' => 'Site Error', 'body' => 'Please try again in a moment.'],
],
],
];
use Contenir\Errors\Mezzio\ErrorPageMiddleware;
use Contenir\Errors\Mezzio\ErrorPageOptions;
use Contenir\Errors\Repository\FileRepository;
use Mezzio\Template\TemplateRendererInterface;
$middleware = new ErrorPageMiddleware(
repository: new FileRepository('/var/www/site/config/autoload/errors.local.php'),
renderer: $container->get(TemplateRendererInterface::class),
logger: $logger,
options: new ErrorPageOptions(viewTemplate: 'error::fault', layout: 'layout::error'),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.