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. Invalid request metadata is rejected with a safe 400 response; other unhandled exceptions are converted to PSR-7 error responses, while {\Lemonade\Framework\Core\handle()} also emits the resulting response to the output.
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, HttpInstrumentation $diagnostics)
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, the kernel creates one from global PHP state. It then creates a {\Lemonade\Framework\Container\ScopeKind::Request} scope, binds the exact request only in that scope, resolves and binds its trusted request context, and delegates dispatch to {\Lemonade\Framework\Core\Framework::runInScope()}. The scope is closed in a finally block. Route-not-found failures are converted to a 404 text response and all other throwables are converted to a 500 text response. Non-routing failures are logged through the sanitized HTTP boundary. Debug mode may include exception details in the response body.
The method does not propagate request failures because it converts them to responses. Invalid HTTP metadata always produces a generic 400 response, including in debug mode.
handle
void
handle(ServerRequestInterface|null $request = null)
Handles an incoming HTTP request and emits the resulting response.
The method executes the same isolated measurement and request-scope lifecycle as {\Lemonade\Framework\Core\run()} before passing the response to the configured emitter.
container
ContainerInterface
container()
Returns the dependency injection container used by the kernel.