Architecture and service management
The Kernel drives application execution, service providers register services, and the DI container creates them and resolves their dependencies.
Lemonade provides a PSR-7 HTTP runtime, PSR-15 middleware, named routes, dependency injection, server-rendered PHP views and console commands.
<?php
declare(strict_types=1);
namespace App\Controllers;
use Lemonade\Framework\View\ViewRendererInterface;
use Psr\Http\Message\ResponseInterface;
final readonly class HomeController
{
public function __construct(
private ViewRendererInterface $views,
) {
}
public function index(): ResponseInterface
{
return $this->views->render('home.index');
}
}The HTTP runtime, routing, dependency injection and CLI form the core. Other modules handle databases, validation, caching and queues.
The Kernel drives application execution, service providers register services, and the DI container creates them and resolves their dependencies.
PSR-7 requests and responses, PSR-15 middleware, routing and controller dispatch.
A shared configuration and service registration model for web requests and console commands.
Database adapters, transactions, schema operations and versioned database migrations.
Validation, caching, sessions, file uploads, localization, events and queues.
The Kernel creates a Request scope, runs PSR-15 middleware, the router selects a ControllerAction, and the emitter sends the resulting PSR-7 response.
An HTTP request enters the application. Lemonade represents it as a PSR-7 ServerRequest containing the method, URI, headers, cookies, uploaded files and parsed body.
ServerRequestInterface · ServerRequestFactory · PSR-7Follow one article API from route registration through controller dependency injection to the JSON response returned to the client.
GET /api/articles/42The router sends the request to the controller.
The controller loads the article through a service that returns a model.
The application returns a PSR-7 JSON response.
The route captures the article ID from the URL and dispatches the controller.
<?php
declare(strict_types=1);
use Demo\ArticleApi\Controllers\ArticleController;
use Lemonade\Framework\Routing\ControllerAction;
use Lemonade\Framework\Routing\Router;
return static function (Router $router): void {
$router->get(
'/api/articles/{id}',
ControllerAction::for(ArticleController::class, 'show'),
);
};<?php
declare(strict_types=1);
namespace Demo\ArticleApi\Controllers;
use Demo\ArticleApi\Services\ArticleService;
use Lemonade\Framework\Http\HttpStatus;
use Lemonade\Framework\Http\Response\Responses;
use Psr\Http\Message\ResponseInterface;
final readonly class ArticleController
{
public function __construct(
private ArticleService $articles,
private Responses $responses,
) {
}
public function show(int $id): ResponseInterface
{
$article = $this->articles->find($id);
if ($article === null) {
return $this->responses->json(['error' => 'Article not found'], HttpStatus::NOT_FOUND->value);
}
return $this->responses->json([
'data' => [
'id' => $article->getId(),
'title' => $article->getTitle(),
],
]);
}
}<?php
declare(strict_types=1);
namespace Demo\ArticleApi\Services;
use Demo\ArticleApi\Models\Article;
final class ArticleService
{
public function find(int $id): ?Article
{
if ($id !== 42) {
return null;
}
return new Article(42, 'First article');
}
}<?php
declare(strict_types=1);
namespace Demo\ArticleApi\Models;
final readonly class Article
{
public function __construct(
private int $id,
private string $title,
) {
}
public function getId(): int
{
return $this->id;
}
public function getTitle(): string
{
return $this->title;
}
}{"data":{"id":42,"title":"First article"}}{"error":"Article not found"}Admin Platform provides an administration runtime, CMS Core provides public CMS routes, and other packages handle pages, news and image variants.
View packages ↗An administration interface with user and role management, DataGrid, editors and audit logging.
02 / CMS routingLemonade CMS CorePublic CMS routing, canonical URLs and shared contracts for content modules.
03 / Content and imagesCMS Page · CMS News · Admin ImageSeparate packages for pages, news and public URLs for image variants.
The chapters cover routing, controllers, views, DI, configuration, databases, middleware, localization, CLI and production operation.