定制 kovagoz/http-responder 二次开发

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

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

kovagoz/http-responder

Composer 安装命令:

composer require kovagoz/http-responder

包简介

A simple solution to create PSR-7 compatible HTTP responses.

README 文档

README

A simple solution to create PSR-7 compatible HTTP responses.

phpunit workflow

Requirements

  • PHP >=8.0

Usage

Instantiate the class:

$responder = new HttpResponder($responseFactory, $streamFactory);

Create HTML response

$response = $responder->reply('hello world');

Create JSON response

$response = $responder->reply(['foo' => 'bar']);

In this case, response body will be the following:

{
  "foo": "bar"
}

Furthermore, Content-Type header will be set to application/json.

Create empty response (204 No Content)

$response = $responder->reply();

Create redirection

$response = $responder->redirect('https://example.com/');

Default status code is 302. You can change it on the response object by the withStatus() method.

You can also pass UriInterface object to the redirect() method instead of string URL.

Testing

This repository contains a Makefile which aids to run unit tests on your computer using a Docker container.

Just run the command below, sit back and watch results.

make test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固