Guide

Errors & Debugging

Error pages, kernel tests, and diagnostics through logs and QA commands.

Custom error pages

Use dedicated views and an error layout for custom 404 or 500 pages. The skeleton shows a basic approach without a special controller hierarchy.

example.php
return $this->view()->template(
    'layouts.error',
    'errors.404',
    [
        'title' => 'Page not found',
    ],
);

HTTP-level tests

For routing, localization, middleware, or controller dispatch, build the kernel in a testing context and send a PSR-7 request through it.

example.php
$kernel = (new KernelFactory())->create($context);
$response = $kernel->run(new ServerRequest('GET', '/articles/123'));

self::assertSame(200, $response->getStatusCode());

Logs, benchmarks, and QA

Start with composer lint, composer stan, and composer test. When request processing breaks, inspect logs and benchmark output first.

example.php
composer lint
composer stan
composer test