定制 tenaga/http 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tenaga/http

Composer 安装命令:

composer require tenaga/http

包简介

Fast & Simple HTTP Component

README 文档

README

Http Foundation for Tenaga Framework Inspired by PatrickLouys/http

How to install?

composer require tenaga\Http

Usage?

Request

Request give some function to access superglobals PHP variables. How to initialize? write some code like below

use Tenaga\Http\Request;  
$request = new Request;
$request->set();

Then you can call some function below

# Get value from $_REQUEST superglobals variables
$request->all($key, $default = null);

# Get value from $_POST superglobals variables
$request->post($key, $default = null);

# Get value from $_GET superglobals variables
$request->get($key, $default = null);

# Get value from $_FILES superglobals variables
$request->file($key, $default = null);

# Get value from $_COOKIE[$key] superglobals variables
$request->cookie($key, $default = null);

# Get all parameters key & value that passe by $_GET and $_POST
$request->parameters();

# Get uri, i.e : test.com/test1/test2/...
$request->uri();

# Get url path, i.e : test1/test2/test3/.../...
$request->path();

# Get method that receive
$request->method();

# Get HTTP_ACCEPT for current request
$request->httpAccept();

# Get HTTP_REFERER for current request
$request->referer();

# Get user agent for current request
$request->userAgent();

# The IP address from which the user is viewing the current page.
$request->ipAddress();

# Check if the current page using https, that will return boolean
$request->isSecure();

Response

Response give some function to prepare response in string type of variables. To initialize write some code below.

use Tenaga\Http\Response;
$response = new Response;

Then you can call some function below

# Set up the response
$response->setResponse($response);

# Get the response, you must add it at end
$response->getResponse();

# Append the current response
$response->appendResponse($response);

Header

Header will give you some function to manipulate header. To initialize write some code below.

use Tenaga\Http\Header;
$header = new Header;

Then you can some function below

# Set status code
$header->setStatusCode($statusCode , $statusText = null);

# Set content type that will show
$header->setContentType($type, $charset = NULL);

# Set expires
$header->setExpired($date);

# Set header
$header->setHeader($name,$value);

# Get all header
$header->getAllHeader();

Cookie

Cookie will give you to easily manipulate and add cookie. To initialize write some code below.

use Tenaga\Http\Cookie;
$cookie = new Cookie;

Then you can some function below

# Set cookie by just passing the cookie by an array
prepare(array $cookie);

# Set cookie name
setName(string $name);

# Set cookie value
setValue($value);

# Set Cookie expired
setExpired(int $time);

# Set cookie path
setPath($path);

# Set Cookie Domain
setDomain($domain);

# Set cookie secure (optional), default : false
setSecure(bool $secure);

# Set Http only (optional), default : false
setHttpOnly(bool $httpOnly);

# Create the cookie
create();

To use cookie you must write code like this

$cookie->prepare
       ->setName('ExampleCookie')
       ->setValue('Example')
       ->setExpired(3600)
       ->setPath('/')
       ->setDomain('localhost.com')
       ->setSecure(true)
       ->setHttpOnly(true)
       ->create();

You can call some or all of them, but you must use prepare for preparing cookie and at the end create() function for making the cookie

Or you can use prepare() function to create new cookie.

/**
 * List Of key of array
 * 0 => name
 * 1 => value
 * 2 => expire
 * 3 => path
 * 4 => domain (optional)
 * 5 => secure (optional)
 * 6 => httponly (optional)
*/
$cookieData = [
  'ExampleCookie',
  'Example',
  3600,
  '/',
  'localhost.com'
];
$cookie->prepare($cookieData)->create();

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固