PHP code example of akrabat / rka-scheme-and-host-detection-middleware

1. Go to this page and download the library: Download akrabat/rka-scheme-and-host-detection-middleware 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/ */

    

akrabat / rka-scheme-and-host-detection-middleware example snippets


$trustedProxies = ['10.0.0.1', '10.0.0.2'];
$app->add(new RKA\Middleware\ProxyDetection($trustedProxies));

$app->get('/', function ($request, $response, $args) {
    $scheme = $request->getUri()->getScheme();
    $host = $request->getUri()->getHost();
    $port = $request->getUri()->getPort();

    return $response;
});