00f100/fcphp-shttp

There is no license information available for the latest version (0.1.1) of this package.

package security web requests

0.1.1 2018-08-04 19:32 UTC

This package is auto-updated.

Last update: 2024-03-18 05:36:48 UTC


README

Library to manipulate auth of user into HTTP env

Build Status codecov Total Downloads

How to install

Composer:

$ composer require 00f100/fcphp-shttp

or add in composer.json

{
    "require": {
        "00f100/fcphp-shttp": "*"
    }
}

How to use

<?php

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();