Get started in a few minutes.

Install the framework, add a route and controller, then check the response in your browser.

Installation

Install the framework

Create a Composer project with PSR-4 autoloading and install the framework package. The final command prepares the directories used below.

Terminal
mkdir lemonade-demo
cd lemonade-demo
composer init --name=demo/lemonade-app --type=project --autoload=app/ --no-interaction
composer require johnnyxlemonade/framework
mkdir -p app/Config app/Controllers public
Project

Explore the project structure

This is the minimal application you will have at the end of the guide. Create public/index.php from the second example now; the route and controller follow in the next steps.

Target project structure
lemonade-demo/
├── app/
│   ├── Config/
│   │   └── Routing.php
│   └── Controllers/
│       └── HomeController.php
├── public/
│   └── index.php
├── composer.json
└── vendor/
public/index.php
<?php

declare(strict_types=1);

use Lemonade\Framework\Core\Context\ApplicationContextFactory;
use Lemonade\Framework\Core\KernelFactory;

require dirname(__DIR__) . '/vendor/autoload.php';

$context = (new ApplicationContextFactory())->fromGlobals(dirname(__DIR__));
$kernel = (new KernelFactory())->create($context);
$kernel->handle();
Routing

Define your first route

Add a named GET route for / to app/Config/Routing.php. It points to the controller’s public index method.

app/Config/Routing.php
<?php

declare(strict_types=1);

use Demo\LemonadeApp\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

Create the controller

Save the class as app/Controllers/HomeController.php. Composer loads it, the framework injects Responses, and the public index method handles the route.

app/Controllers/HomeController.php
<?php

declare(strict_types=1);

namespace Demo\LemonadeApp\Controllers;

use Lemonade\Framework\Http\Response\Responses;
use Psr\Http\Message\ResponseInterface;

final class HomeController
{
    public function __construct(private readonly Responses $responses)
    {
    }

    public function index(): ResponseInterface
    {
        return $this->responses->html('<h1>Hello from Lemonade!</h1>');
    }
}
Run

Run the app and check the result

Start PHP’s built-in server from the project root and open http://localhost:8000/. You should see HTTP 200 and the heading “Hello from Lemonade!”.

Terminal
php -S localhost:8000 -t public
Where next

Explore more topics.

Examples

Routing, controllers, middleware, and other components in focused technical articles.

All examples

Documentation

Configuration, APIs, and component behavior explained chapter by chapter.

Open documentation

Need help?

If installation or the first route fails, send the exact error and a description of your environment.

Contact support