PHP code example of snicco / content-negotiation-middleware
1. Go to this page and download the library: Download snicco/content-negotiation-middleware library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
snicco / content-negotiation-middleware example snippets
// In your container definitions
use Snicco\Middleware\Negotiation\NegotiateContent;
// basic configuration based on defaults.
$negotiation = new NegotiateContent(
['en'] // content languages
);
// With custom configuration for content-types your application can provide (sorted by priority)
$negotiation = new NegotiateContent(
['en'],
[
'html' => [
'extension' => ['html', 'php'],
'mime-type' => ['text/html'],
'charset' => true,
],
'txt' => [
'extension' => ['txt'],
'mime-type' => ['text/plain'],
'charset' => true,
],
'json' => [
'extension' => ['json'],
'mime-type' => ['application/json'],
'charset' => true,
],
]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.