定制 neat/http 二次开发

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

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

neat/http

最新稳定版本:0.7.0

Composer 安装命令:

composer require neat/http

包简介

Neat HTTP components

README 文档

README

Stable Version Build Status

Neat HTTP components provide a clean and expressive API for your application to access HTTP messages.

Requirements

To use Neat HTTP components you will need

To send and receive messages, we suggest using the neat/http-client and neat/http-server packages.

Getting started

To install this package, simply issue composer on the command line:

composer require neat/http

Reading the request

The request can be read using simple methods like shown below.

<?php /** @var Neat\Http\ServerRequest $request */

// Get ?page= query parameter
$page = $request->query('page');

// Get posted name field
$name = $request->post('name');

// Or just get all posted fields
$post = $request->post();

// Who doesn't want a cookie
$preference = $request->cookie('preference');

// Get the request method
$method = $request->method();

// And of course the requested URL
$url = $request->url();

URL inspection

To save you the trouble of dissecting and concatenating URL's by hand, the URL class will lend you a hand:

<?php /** @var Neat\Http\Url $url */

// You can easily print the URL because it converts to a string when needed
echo $url;

// Or get parts of the url separately
$url->scheme();   // 'https'
$url->username(); // ''
$url->password(); // ''
$url->host();     // 'example.com'
$url->port();     // null
$url->path();     // '/articles'
$url->query();    // 'page=2'
$url->fragment(); // ''

// Do you want to create a slightly different URL based on this one?
$mutation = $url->withPath('/just')->withQuery('tweak=any&part=youlike');

File uploads

Uploaded files can be accessed through the request using the file method.

<?php /** @var Neat\Http\ServerRequest $request */

// Get uploaded file with the name avatar
$file = $request->files('avatar');

// Check the error status
if (!$file->ok()) {
    echo 'Upload error id = ' . $file->error();
}

// Get the file name, size and mime type
$file->clientName(); // 'selfie.jpg' <-- provided by the client, so consider it unsafe user input
$file->clientType(); // 'image/jpeg' <-- provided by the client, so consider it unsafe user input
$file->size(); // 21359

// Move the file from its temporary location
$file->moveTo('destination/path/including/filename.jpg');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固