First steps / PHP 8.3+
Installation, a route and a controller.
Install the Composer package, register a named route with ControllerAction::for(), and return a PSR-7 response from a controller.
First installation
01 / Add the framework.
Lemonade requires PHP 8.3–8.5. Installing the Composer package does not create an application: the host project still owns its entrypoint and bootstrap.
Terminal
composer require johnnyxlemonade/frameworkThe framework is in pre-release. Review public API compatibility and package requirements in the README before deployment.
Routing
02 / Define your first route.
app/Config/Routing.php returns a closure receiving the Router. A handler is an explicit pair of controller class and public method.
app/Config/Routing.php
<?php
use App\Controllers\HomeController;
use Lemonade\Framework\Routing\ControllerAction;
use Lemonade\Framework\Routing\Router;
return static function (Router $router): void {
$router->getNamed(
'home',
'/',
ControllerAction::for(HomeController::class, 'index'),
);
};Controller
03 / Return a response.
A controller is a plain final class. The renderer is constructor-injected in Request scope and returns a PSR-7 Response.
app/Controllers/HomeController.php
<?php
namespace App\Controllers;
use Lemonade\Framework\View\ViewRendererInterface;
use Psr\Http\Message\ResponseInterface;
final class HomeController
{
public function __construct(
private readonly ViewRendererInterface $views,
) {}
public function index(): ResponseInterface
{
return $this->views->render('home.index');
}
}Continue with the documentation
Open documentation ↗Configuration, providers and the full HTTP bootstrap flow are covered in more detail in the repository.