Core

Core Service Provider

Minimal runtime primitives shared by HTTP and CLI framework bootstrapping.

Responsibility

Registers low-level framework primitives used by other providers: PSR-7/PSR-17 factories, framework ServerRequestFactory, controller resolver, base URL resolver, loader adapter, framework metadata, exception logger and clock service.

Bootstrap services

Framework registers ApplicationContext, alias context, Environment, Config, alias config, ContainerInterface, Router, the framework logger and benchmark services before provider registration. CoreServiceProvider can therefore consume Config and should not be confused with the bootstrap step that creates it.

Config service

Config stores merged framework and application configuration. It supports dot notation with get(), require(), string(), requiredString(), int(), bool(), array(), set() and merge().

use Lemonade\Framework\Core\Config;

$config = $container->get('config');

$appName = $config->string('app.name', 'Lemonade');
$debug = $config->bool('app.debug');
$providers = $config->array('framework.providers');

Application context

ApplicationContext is a bootstrap runtime object, not registered by CoreServiceProvider, but it is part of the minimal core runtime. It exposes environment, debug mode and path helpers such as basePath(), appPath(), configPath(), storagePath(), resolveWritablePath(), resolveLogPath(), resolveUploadPath() and resolveCachePath().

use Lemonade\Framework\Core\Context\ApplicationContext;

$context = $container->get(ApplicationContext::class);

$basePath = $context->basePath();
$logPath = $context->resolveLogPath('app.log');

PSR factories

CoreServiceProvider registers Nyholm Psr17Factory and binds it to PSR factory interfaces: ResponseFactoryInterface, RequestFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface and UriFactoryInterface. It also exposes aliases such as psr17 and http.responseFactory.

use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;

$responses = $container->get(ResponseFactoryInterface::class);
$streams = $container->get(StreamFactoryInterface::class);

$response = $responses
    ->createResponse(200)
    ->withBody($streams->createStream('OK'));

Server requests

Lemonade\Framework\Http\Psr\ServerRequestFactory creates ServerRequestInterface from PHP globals through Nyholm server request creation. HTTP Kernel::handle() uses it when no request object is supplied.

use Lemonade\Framework\Http\Psr\ServerRequestFactory;

$request = $container
    ->get(ServerRequestFactory::class)
    ->fromGlobals();

Resolver utilities

ControllerResolver resolves controller targets through the container and prepares controller execution context. LoaderAdapter is a core adapter utility, and BaseUrlResolver resolves configured or server-derived base URLs through alias baseUrl.

use Lemonade\Framework\Support\BaseUrlResolver;

$baseUrl = $container
    ->get(BaseUrlResolver::class)
    ->baseUrl('/assets/app.css');

Diagnostics

ExceptionLogger centralizes safe exception logging for kernels and middleware. It is intentionally defensive: logging failures should not break error handling. FrameworkInfo exposes framework name, version and powered-by header metadata used by HTTP middleware.

Clock

CoreServiceProvider binds ClockInterface to SystemClock and alias clock. The clock timezone is read from app.timezone; invalid timezone values fail during provider registration.

use Lemonade\Framework\Clock\ClockInterface;

$now = $container
    ->get(ClockInterface::class)
    ->now();

Provider boundary

CoreServiceProvider is intentionally small. It does not register HTTP middleware, routing, views, database, validation, queue, events, console commands or application domain services; those belong to dedicated providers.

HTTP client note

CoreServiceProvider does not bind a PSR-18 HTTP client. Outbound HTTP client integration is provided by dedicated client providers, so applications can choose the concrete client implementation independently.