PHP code example of koine / http

1. Go to this page and download the library: Download koine/http 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/ */

    

koine / http example snippets



namespace Koine\Http;

$env     = new Environment($_SERVER);
$cookies = new Cookies($_COOKIE);
$session = new Session($_SESSION);
$params  = new Params($_REQUEST);

$request = new Request(array(
    'environment' => $env,
    'cookies'     => $cookies,
    'session'     => $session,
    'params'      => $params,
));

$hello = function ($request) {

    $response = new Response(array(
        'cookies' => $cookies,
    ));

    return $response->setBody('Hello Word!');
};

// If page is hello

$hello()->send();

$redirect = function ($request) {

    $response = new Response(array(
          'cookies' => $cookies,
    ));

    return $response->setRedirect('/');
};

// If page is redirect

$redirect()->send();