Lemonade in practice.

Concrete uses of routing, controllers, services, middleware, views, JSON APIs, localization, and CLI commands in application code.

Selected example

01 / Routing

Route definitions, HTTP methods, URL parameters, and controller actions.

Open example
app/Config/Routing.phpPHP
<?php

declare(strict_types=1);

use App\Controllers\ArticleController;
use Lemonade\Framework\Routing\ControllerAction;
use Lemonade\Framework\Routing\Router;

return static function (Router $router): void {
    $router->getNamed(
        'articles.detail',
        '/articles/{id}',
        ControllerAction::for(ArticleController::class, 'detail'),
    );
};

In this file

Routing.php returns a callback that receives the router. The named GET route maps /articles/{id} to ArticleController::detail().

  • a GET route for /articles/{id}
  • passing the id parameter to the action
  • binding the controller through ControllerAction::for()
More topics

Explore more examples.

Services, middleware, views, localization, and CLI each have their own steps and source files.