PHP 8.3–8.6 · PSR-7 · PSR-15

A PHP framework for web and CLI.

Lemonade provides a PSR-7 HTTP runtime, PSR-15 middleware, named routes, dependency injection, server-rendered PHP views and console commands.

HTTP RUNTIME · DI CONTAINER · CLI
app/Controllers/HomeController.phpPHP 8.3–8.6
<?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');
    }
}
●  Constructor DI · PSR-7 · ViewsPSR-7 / PSR-15
{ services }CONSTRUCTOR DI · REQUEST SCOPE
01 / PHP 8.3+02 / PSR-7 & PSR-1503 / SERVICE PROVIDERS · TYPED CONFIG04 / WEB + CLI↘ SCROLL DOWN
Framework components

Core
components.

The HTTP runtime, routing, dependency injection and CLI form the core. Other modules handle databases, validation, caching and queues.

01 / APPLICATION FOUNDATION

Architecture and service management

The Kernel drives application execution, service providers register services, and the DI container creates them and resolves their dependencies.

KernelProvidersDI Container
02 / HTTP LAYER

HTTP and PSR standards

PSR-7 requests and responses, PSR-15 middleware, routing and controller dispatch.

Request → Middleware → Response
03 / WEB AND CLI

HTTP and console applications

A shared configuration and service registration model for web requests and console commands.

KernelCliKernel
04 / DATA

Databases and migrations

Database adapters, transactions, schema operations and versioned database migrations.

DatabaseMigrations
05 / ADDITIONAL COMPONENTS

Other services

Validation, caching, sessions, file uploads, localization, events and queues.

ValidationCacheQueues
HTTP lifecycle

From request
to response.

The Kernel creates a Request scope, runs PSR-15 middleware, the router selects a ControllerAction, and the emitter sends the resulting PSR-7 response.

STEP 0101

Request

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-7
PSR-7 REQUEST / PSR-15 MIDDLEWARE / PSR-7 RESPONSEKERNEL → ROUTER → CONTROLLER →
API examples

A simple API in practice.

Follow one article API from route registration through controller dependency injection to the JSON response returned to the client.

RequestGET /api/articles/42
  1. The router sends the request to the controller.

  2. The controller loads the article through a service that returns a model.

  3. The application returns a PSR-7 JSON response.

The route captures the article ID from the URL and dispatches the controller.

  LEMONADE / API EXAMPLEPHP 8.3+
app/Config/Routing.php
<?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'),
    );
};
Routing · Constructor DI · PSR-7 JSONPHP 8.3+   /   UTF-8
View all examples

Build your first application.

Follow the installation and basic configuration steps, then create your first application.