alexya-framework/http 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

alexya-framework/http

Composer 安装命令:

composer require alexya-framework/http

包简介

Alexya's HTTP components

README 文档

README

Alexya's HTTP components

Contents

Request

The class \Alexya\Http\Request offers a wrapper for the request supergloblas ($_GET, $_POST...).

You can retrieve the request with the method main.

The constructor accepts the following parameters:

  • A string being the requested URI.
  • An array being GET parameters.
  • An array being POST parameters.
  • An array being COOKIE parameters.
  • An array being SERVER parameters.

Example:

<?php

$request = new \Alexya\Http\Request(
    $_SERVER["REQUEST_URI"],
    $_GET,
    $_POST,
    $_COOKIES,
    $_FILES,
    $_SERVER
); // Which is the same as `$request = \Alexya\Http\Request::main();`

echo $request->get["param_name"];

foreach($request->headers as $key => $value) {
    echo "Requested header: {$key}: {$value}";
}

Response

The class \Alexya\Http\Response offers a way for create and send HTTP responses.

The constructor accepts the following parameters (all of them optional):

  • An array being the headers.
  • A string being the response body.
  • An integer being the status code (or a string being the status name).

To send the request use the method send.

To add a new header use the method header which accepts as parameter a string being the header name and a string or an array being the value of the header.

The method status sets the status code of the response, it can be either an integer being the code or a string being the name (see Response::responseCodes).

The method redirect sends a redirect response thrugh headers. It accepts as parameter a string being the URL to redirect, a string being the method of redirect ("Refresh" or "Location") and the status code of the redirect.

Example:

<?php

$request = new Request();

$request->header("Content-Type", "text/html");
$request->status(200);
$request->body("<h1>Hello World</h1>");

Request::redirect("/Home");

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GNU
  • 更新时间: 2016-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固