innmind/http 问题修复 & 功能扩展

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

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

innmind/http

Composer 安装命令:

composer require innmind/http

包简介

Value Objects to abstract http messages

README 文档

README

Build Status codecov Type Coverage

Immutable value objects and interfaces to abstract http messages.

Important: you must use vimeo/psalm to make sure you use this library correctly.

Build a ServerRequest

use Innmind\Http\Factory\ServerRequestFactory;
use Innmind\TimeContinuum\Clock;

$request = ServerRequestFactory::native(Clock::live())();

Send a Response

use Innmind\Http\{
    Response,
    Response\StatusCode,
    Response\Sender\Native,
    ProtocolVersion,
    Headers,
    Header,
    Header\ContentType,
};
use Innmind\Filesystem\File\Content;
use Innmind\TimeContinuum\Clock;

$response = Response::of(
    StatusCode::ok,
    ProtocolVersion::v11,
    Headers::of(
        ContentType::of('application', 'json'),
    ),
    Content::ofString('{"some": "data"}'),
);

Native::of(Clock::live()))($response);

will build the following message:

HTTP/1.1 200 OK
Date: Wed, 04 May 2016 14:24:14 +0000
Content-Type : application/json

{"some": "data"}

Build a multipart Request

use Innmind\Http\{
    Request,
    Method,
    Content\Multipart,
    Header\ContentType\Boundary,
    Headers,
    ProtocolVersion,
};
use Innmind\Filesystem\{
    File,
    File\Content,
};
use Innmind\Url\Url;

$boundary = Boundary::uuid();
$request = Request::of(
    Url::of('http://some-server.com/')
    Method::post,
    ProtocolVersion::v11,
    Headers::of($boundary->toHeader()),
    Multipart::boundary($boundary)
        ->with('some[key]', 'some value')
        ->withFile('some[file]', File::named(
            'whatever.txt',
            Content::ofString(' can be any file content'),
        )),
);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固