elife / content-negotiator
eLife Sciences 内容协商者
v1.0.1
2018-03-16 09:05 UTC
Requires
- php: ^7.0
- symfony/http-foundation: ^2.7 || ^3.0
- symfony/http-kernel: ^2.7 || ^3.0
- willdurand/negotiation: ^2.0.2
Requires (Dev)
- phpunit/phpunit: ^5.7.7 || ^6.0
- pimple/pimple: ^3.0
- silex/silex: ^2.0
- symfony/browser-kit: ^2.7 || ^3.0
- symfony/css-selector: ^2.7 || ^3.0
- symfony/debug: ^2.8 || ^3.0
Suggests
- silex/silex: ^2.0, to use ContentNegotiationProvider
This package is auto-updated.
Last update: 2024-09-12 02:38:11 UTC
README
此库为Negotiation提供了一个包装器。
依赖项
- Composer
- PHP 7
安装
composer require elife/content-negotiator
设置
Silex
use eLife\ContentNegotiator\Silex\ContentNegotiationProvider; use Negotiation\Accept; $app->register(new ContentNegotiationProvider()); $app->get('/path', function (Accept $accept) { return new Response("Negotiated {$accept->getNormalizedValue()}"); })->before($app['negotiate.accept']('text/plain', 'text/rtf'));
当使用symfony/http-kernel
3.1+时,你可以在控制器中用以下类型之一对参数进行类型提示,协商的结果将被使用
运行测试
vendor/bin/phpunit