承接 chubbyphp/chubbyphp-negotiation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

chubbyphp/chubbyphp-negotiation

最新稳定版本:2.3.0

Composer 安装命令:

composer require chubbyphp/chubbyphp-negotiation

包简介

Chubbyphp Negotiation

README 文档

README

CI Coverage Status Mutation testing badge Latest Stable Version Total Downloads Monthly Downloads

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A simple negotiation library.

Requirements

  • php: ^8.3
  • psr/http-message: ^1.1|^2.0

Suggest

  • chubbyphp/chubbyphp-container: ^2.3
  • chubbyphp/chubbyphp-http-exception: ^1.2
  • chubbyphp/chubbyphp-laminas-config-factory: ^1.4
  • pimple/pimple: ^3.6
  • psr/http-server-middleware: ^1.0.2

Installation

Through Composer as chubbyphp/chubbyphp-negotiation.

composer require chubbyphp/chubbyphp-negotiation "^2.3"

Usage

AcceptLanguageNegotiator

<?php use Chubbyphp\Negotiation\AcceptLanguageNegotiator; $request = ...; $request->withHeader('Accept-Language', 'de,en-US;q=0.7,en;q=0.3'); $negotiator = new AcceptLanguageNegotiator(['en', 'de']); $value = $negotiator->negotiate($request); // NegotiatedValue $value->getValue(); // de $value->getAttributes(); // ['q' => '1.0']

AcceptLanguageMiddleware

<?php use Chubbyphp\Negotiation\Middleware\AcceptLanguageMiddleware; $request = ...; $request->withHeader('Accept-Language', 'de,en-US;q=0.7,en;q=0.3'); $middleware = new AcceptLanguageMiddleware($acceptLanguageNegotiator); $response = $negotiator->process($request, $handler);

AcceptNegotiator

<?php use Chubbyphp\Negotiation\AcceptNegotiator; $request = ...; $request->withHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q =0.8'); $negotiator = new AcceptNegotiator(['application/json', 'application/xml', 'application/x-yaml']); $value = $negotiator->negotiate($request); // NegotiatedValue $value->getValue(); // application/xml $value->getAttributes(); // ['q' => '0.9']

AcceptMiddleware

<?php use Chubbyphp\Negotiation\Middleware\AcceptMiddleware; $request = ...; $request->withHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q =0.8'); $middleware = new AcceptMiddleware($acceptNegotiator); $response = $negotiator->process($request, $handler);

ContentTypeNegotiator

<?php use Chubbyphp\Negotiation\ContentTypeNegotiator; $request = ...; $request->withHeader('Content-Type', 'application/xml; charset=UTF-8'); $negotiator = new ContentTypeNegotiator(['application/json', 'application/xml', 'application/x-yaml']); $value = $negotiator->negotiate($request); // NegotiatedValue $value->getValue(); // application/xml $value->getAttributes(); // ['charset' => 'UTF-8']

ContentTypeMiddleware

<?php use Chubbyphp\Negotiation\Middleware\ContentTypeMiddleware; $request = ...; $request->withHeader('Content-Type', 'application/xml; charset=UTF-8'); $middleware = new ContentTypeMiddleware($contentTypeNegotiator); $response = $negotiator->process($request, $handler);

NegotiationServiceFactory

<?php use Chubbyphp\Container\Container; use Chubbyphp\Negotiation\ServiceFactory\NegotiationServiceFactory; use Psr\Http\Message\ServerRequestInterface; $container = new Container(); $container->factories((new NegotiationServiceFactory())()); $request = ...; $container->get('negotiator.acceptNegotiator') ->negotiate($request); $container->get('negotiator.acceptMiddleware') ->process($request, $handler); $container->get('negotiator.acceptLanguageNegotiator') ->negotiate($request); $container->get('negotiator.acceptLanguageMiddleware') ->process($request, $handler); $container->get('negotiator.contentTypeNegotiator') ->negotiate($request); $container->get('negotiator.contentTypeMiddleware') ->process($request, $handler);

NegotiationServiceProvider

<?php use Chubbyphp\Negotiation\ServiceProvider\NegotiationServiceProvider; use Pimple\Container; use Psr\Http\Message\ServerRequestInterface; $container = new Container(); $container->register(new NegotiationServiceProvider); $request = ...; $container['negotiator.acceptNegotiator'] ->negotiate($request); $container['negotiator.acceptMiddleware'] ->process($request, $handler); $container['negotiator.acceptLanguageNegotiator'] ->negotiate($request); $container['negotiator.acceptLanguageMiddleware'] ->process($request, $handler); $container['negotiator.contentTypeNegotiator'] ->negotiate($request); $container['negotiator.contentTypeMiddleware'] ->process($request, $handler);

ServiceFactory

Copyright

2025 Dominik Zogg

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固