PHP code example of innmind / http-framework

1. Go to this page and download the library: Download innmind/http-framework library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

innmind / http-framework example snippets



# 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),
                        ),
                    ),
                );
            });
    }
}