PHP code example of 00f100 / fcphp-shttp

1. Go to this page and download the library: Download 00f100/fcphp-shttp 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/ */

    

00f100 / fcphp-shttp example snippets




use FcPhp\SHttp\SHttp;
use FcPhp\SHttp\SEntity;
use FcPhp\Session\Facades\SessionFacade;

$session = SessionFacade::getInstance($_COOKIE);
$entity = new SEntity();

$instance = new SHttp($_POST, $_SERVER, $entity, $session);

$instance->callback('authHeaderCallback', function(ISEntity $entity, $authHeader) {
    $entity->setName('Header Auth');
    return $entity;
});

$instance->callback('authSessionCallback', function(ISEntity $entity, $authSession) {
    $entity->setName('Session Auth');
    return $entity;
});

$instance->callback('authUserPassCallback', function(ISEntity $entity, $authUserPass) {
    $entity->setName('User Pass Auth');
    return $entity;
});

$entity = $instance->get();

// PRINT:
// IF HEADER AUTH: Header Auth
// IF SESSION AUTH: Session Auth
// IF POST AUTH: User Pass Auth
echo $entity->getName();