00f100 / fcphp-shttp
此包最新版本(0.1.1)没有可用的许可证信息。
包安全网络请求
0.1.1
2018-08-04 19:32 UTC
Requires
- php: >=7.2
- 00f100/array_dot: 0.*
- 00f100/fcphp-session: 0.*
Requires (Dev)
- 00f100/phpdbug: *
- phpunit/phpunit: 6.*
This package is auto-updated.
Last update: 2024-09-18 06:38:30 UTC
README
用于操作用户HTTP环境中的身份验证的库
如何安装
Composer
$ composer require 00f100/fcphp-shttp
或者在composer.json中添加
{ "require": { "00f100/fcphp-shttp": "*" } }
如何使用
<?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();