定制 danharper/psr7-jsonx 二次开发

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

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

danharper/psr7-jsonx

Composer 安装命令:

composer require danharper/psr7-jsonx

包简介

JSONx is JSON encoded as XML

README 文档

README

Latest Stable Version License

An incoming Request object with a Content-Type: application/xml header, will be converted to a JSON Request.

An outgoing Response object with a Content-Type: application/json header with a corresponding Request object with a Accept: application/xml header, will be converted to an XML Response.

It does this using IBM's standard for representing JSON as XML: JSONx.

This library is just a small wrapper around danharper/jsonx. And, if you're using Laravel, you can get full JSONx just by dropping in a middleware with danharper/laravel-jsonx.

Notice The library changes the body of HTTP Messages, and so it needs an implementation of Psr\Http\Message\StreamInterface to work. Or, I might be missing a better way?

There's a StreamFactoryInterface you can implement to do it, or there's two implementations: DiactorosStreamFactory (for the zend/diactoros PSR-7 implementation) and a CallableStreamFactory which you provide a function which will be given a string and you must return a stream containing it.

$jsonxAdaptor = new JSONxPSR7(new DiactorosStreamFactory);

// or instead of DiactorosStreamFactory, implement your own, or use:

$streamFactory = new CallableStreamFactory(function($body) { return MyPsr7Stream::fromString($body); });
$jsonxAdaptor = new JSONxPSR7($streamFactory);

Installation

composer require danharper/psr7-jsonx

Example

Convert Requests like so:

$request = $jsonxAdaptor->request($request);

Convert Responses like so:

$response = $jsonxAdaptor->response($request, $response);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固