Kernel
final class Kernel (View source)
HTTP application kernel for Lemonade Framework applications.
The kernel bootstraps the application, loads configuration, registers core and application service providers, registers routes, and runs the framework request pipeline. Unhandled exceptions are converted to PSR-7 error responses, while {\Lemonade\Framework\Core\handle()} also emits the resulting response to the output.
Traits
Methods
Accepts the runtime services used by the HTTP kernel.
Bootstraps the HTTP kernel once for the current instance.
Boots the kernel and runs the request through the framework runtime.
Handles an incoming HTTP request and emits the resulting response.
Returns the dependency injection container used by the kernel.
Returns the application context used during kernel bootstrap.
Details
__construct
__construct(ApplicationContext $context, ContainerInterface $container, Framework $framework, ResponseEmitter $emitter, FrameworkHealthFastPath $healthFastPath, Benchmark $benchmark)
Accepts the runtime services used by the HTTP kernel.
Bootstrap is performed lazily through {\Lemonade\Framework\Core\bootstrap()} when the kernel first handles or runs a request.
bootstrap
void
bootstrap()
Bootstraps the HTTP kernel once for the current instance.
When the kernel has already been booted, the method returns without doing any further work. Otherwise it loads application configuration files, applies runtime app configuration, prepares core diagnostics and logging, registers shared and HTTP framework providers, registers configured application providers, loads routes from the Routing.php file, and marks the kernel as booted.
The method is idempotent for a single kernel instance.
run
ResponseInterface
run(ServerRequestInterface|null $request = null)
Boots the kernel and runs the request through the framework runtime.
When no request is provided, request creation is delegated to {\Lemonade\Framework\Core\Framework::run()}. Route-not-found failures are converted to a 404 text response and all other throwables are converted to a 500 text response. Captured exceptions are recorded in the benchmark and logged, and debug mode may include exception details in the response body.
The method does not propagate exceptions because it converts them to responses.
handle
void
handle(ServerRequestInterface|null $request = null)
Handles an incoming HTTP request and emits the resulting response.
The method starts the HTTP benchmark, creates a request from PHP globals through the server request factory when none is supplied, runs the kernel, and emits the final response through the configured response emitter.
This is the HTTP entrypoint and has the side effect of writing the response to the output.
container
ContainerInterface
container()
Returns the dependency injection container used by the kernel.