innmind/http-framework

This package is abandoned and no longer maintained. The author suggests using the innmind/framework package instead.

HTTP framework

2.3.0 2021-02-15 16:52 UTC

This package is auto-updated.

Last update: 2023-01-01 15:05:05 UTC


README

Build Status codecov Type Coverage

Library to formalize http request handling and provide generic tools such as routing.

Installation

composer require innmind/http-framework

Usage

<?php
# index.php

use function Innmind\HttpFramework\bootstrap;
use Innmind\HttpFramework\{
    Controller,
    Application,
    Main,
};
use Innmind\Url\Path;
use Innmind\Immutable\Map;

new class extends Main {
    protected function configure(Application $app): Application
    {
        return $app
            ->configAt(Path::of('/folder/containing/dotenv_file/'))
            ->handler(static function($os, $env) {
                $framework = bootstrap();

                return $framework['enforce_https'](
                    $framework['authenticate']($authenticator, $condition)(
                        $framework['router'](
                            /* instance of Innmind\Router\RequestMatcher */,
                            Map::of('string', Controller::class),
                        ),
                    ),
                );
            });
    }
}