Guide
Routing
Named routes, parameters, and localization only where the URL strategy actually needs them.
Start with simple named routes
Begin with getNamed(), postNamed(), and similar methods in app/Config/Routing.php. This is the clearest starting point for a new project and matches the application skeleton.
<?php
use App\Controllers\ArticleController;
use Lemonade\Framework\Routing\Router;
return static function (Router $router): void {
$router->getNamed(
'articles.detail',
'/articles/{id}',
ArticleController::class . '@detail',
);
};Route parameters and URL generation
Route parameters are passed to action arguments by name. Generate URLs through UrlGenerator or view helpers instead of hardcoding paths.
$url = $this->url()->route('articles.detail', [
'id' => 123,
'preview' => 1,
]);Localized routes are optional
Use localizedGroup() only when the application truly needs locale-dependent URLs. It does not need to appear in every project’s first example. Once the basic routing flow is clear, continue with Middleware for shared request rules and Forms & POST Workflow for state-changing forms.
$router->localizedGroup(static function (Router $router): void {
$router->getNamed('home.index', '/', 'HomeController@index');
});