Debug
Debug komponenta s dumper service, zachycením contextu a výběrem CLI/HTML rendereru.
Overview
Debug module provides runtime dump tooling (dump, dd, DumperInterface) and debug-mode-dependent error output in kernels. It is not a web profiler or debug toolbar.
Debug mode
Debug mode is part of ApplicationContext (DebugMode). ApplicationContextFactory resolves it from APP_DEBUG; if not set, it falls back to environment default from APP_ENV (dev/test => debug on, prod => debug off).
APP_ENV=development
APP_DEBUG=true
Runtime behavior
HTTP runtime (Kernel) and CLI runtime (CliKernel) both use ApplicationContext::debug(). In debug mode, kernel error responses include exception detail/trace text and CLI prints stack trace on unhandled exception. Outside debug mode, responses/errors are minimal.
Registered services
DebugServiceProvider registers dump services: DumpOptions, DumpContextFactory, ValueInspectorInterface (NativeValueInspector), DumpOutputInterface (EchoOutput), CliDumpRenderer, HtmlDumpRenderer, DumpRendererResolver, Dumper, DumperInterface, and alias dumper.
$container->singleton(Dumper::class, Dumper::class);
$container->singleton(
DumperInterface::class,
static fn(ContainerInterface $container): DumperInterface => $container->get(Dumper::class),
);
$container->singleton(
'dumper',
static fn(ContainerInterface $container): DumperInterface => $container->get(DumperInterface::class),
);
Error handling
Unhandled exceptions are logged through ExceptionLogger in both kernels. In HTTP runtime, debug mode affects body of 404/500 plain-text responses. In CLI runtime, debug mode controls whether stack trace is printed to stderr after CLI error: ... message.
Relation to observability
Debug and observability are complementary. Debug focuses on local inspection (dump/dd and verbose errors), while observability/logging/benchmark provide runtime telemetry and persistent diagnostics.
Example
Typical local setup enables debug explicitly and keeps production off.
# local
APP_ENV=development
APP_DEBUG=true
# production
APP_ENV=production
APP_DEBUG=false