final class Framework (View source)

Main bootstrap and runtime facade for the Lemonade Framework HTTP application layer.

The facade coordinates service provider registration, configuration definitions, localized route setup, middleware configuration, and execution of the PSR-15 request pipeline. It operates on top of the supplied dependency injection container and application context.

Methods

Creates a framework runtime bound to the provided container and application context.

Returns the application context used during framework bootstrap.

Registers one or more service providers in the order they are supplied.

routes(callable $builder)

Configures application routes through the framework router.

routesFromFile(string $file)

Loads route definitions from a PHP file returning a router configurator callback.

Registers configuration definitions and merges their serialized data into runtime config state.

configFromFile(string $file, string|null $rootKey = null)

Loads a configuration definition from file through the config file loader.

middleware(callable $configure)

Configures the framework middleware stack.

ResponseInterface
run(ServerRequestInterface|null $request = null)

Runs an HTTP request through the configured middleware pipeline.

ResponseInterface

Returns the framework dependency injection container.

Details

__construct

__construct(ContainerInterface $container, ApplicationContext $context)

Creates a framework runtime bound to the provided container and application context.

The constructor initializes the framework router and registers the core framework services required for configuration loading and request handling.

Parameters

ContainerInterface $container
ApplicationContext $context

context

Returns the application context used during framework bootstrap.

Return Value

ApplicationContext

register

Registers one or more service providers in the order they are supplied.

Parameters

ServiceProviderInterface ...$providers

Return Value

Framework

Returns the same framework instance for fluent chaining.

routes

Framework routes(callable $builder)

Configures application routes through the framework router.

Localized route settings are applied before the callback is invoked.

Parameters

callable $builder

Return Value

Framework

Returns the same framework instance for fluent chaining.

routesFromFile

Framework routesFromFile(string $file)

Loads route definitions from a PHP file returning a router configurator callback.

Localized route settings are applied before the loaded callback is invoked.

Parameters

string $file

Return Value

Framework

Returns the same framework instance for fluent chaining.

Exceptions

RuntimeException
RuntimeException

config

Registers configuration definitions and merges their serialized data into runtime config state.

Definitions are processed in the order they are supplied.

Parameters

ConfigDefinitionInterface ...$definitions

Return Value

Framework

Returns the same framework instance for fluent chaining.

configFromFile

Framework configFromFile(string $file, string|null $rootKey = null)

Loads a configuration definition from file through the config file loader.

When provided, the root key selects the root section to load from the file.

Parameters

string $file
string|null $rootKey

Return Value

Framework

Returns the same framework instance for fluent chaining.

middleware

Framework middleware(callable $configure)

Configures the framework middleware stack.

If the middleware stack is already available in the container, the callback is applied immediately. Otherwise, it is deferred until just before the request pipeline is executed.

Parameters

callable $configure

Return Value

Framework

Returns the same framework instance for fluent chaining.

run

ResponseInterface run(ServerRequestInterface|null $request = null)

Runs an HTTP request through the configured middleware pipeline.

When no request is supplied, a server request is created from global PHP state through the server request factory. Any deferred middleware configuration is applied before middleware is resolved, and the pipeline terminates in the dispatch request handler.

Parameters

ServerRequestInterface|null $request

Return Value

ResponseInterface

container

Returns the framework dependency injection container.

Return Value

ContainerInterface