Download the PHP package mleczek/laravel-negotiator without Composer
On this page you can find all versions of the php package mleczek/laravel-negotiator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mleczek/laravel-negotiator
More information about mleczek/laravel-negotiator
Files in mleczek/laravel-negotiator
Package laravel-negotiator
Short Description Content negotiation for Laravel API
License MIT
Homepage https://github.com/mleczek/laravel-negotiator
Informations about the package laravel-negotiator
Content negotiation for Laravel API
- Installation
- Usage
- Extending
- Contributing
- License
Installation
Require this package with composer:
In config/app.php
add the NegotiatorServiceProvider
:
Usage
Package provide negotiate
macro for ResponseFactory
:
The same result can be achieved using Mleczek\Negotiator\ContentNegotiation
class:
For both negotiate
method and macro there is also one parameter which override result for specified content types:
By default package support application/json
and application/xml
. XML format is resolved using mleczek/xml
package.
Extending
You can extend supported content types in boot
method of any of your ServiceProvider
:
The first parameter accept content type (or array of content types) for which the specified handler should be used.
Handler must implement the Mleczek\Negotiator\Contracts\ContentNegotiationHandler
interface.
Contributing
Thank you for considering contributing! If you would like to fix a bug or propose a new feature, you can submit a Pull Request.
License
The library is licensed under the MIT license.