1. Go to this page and download the library: Download bear/accept 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/ */
bear / accept example snippets
use Ray\Di\AbstractModule;
use Ray\Di\Scope;
class AppModule extends AbstractModule
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$available = [
'Accept' => [
'application/hal+json' => 'prod-hal-app',
'application/json' => 'prod-app',
'text/csv' => 'prod-csv-app',
'cli' => 'prod-html-app'
],
'Accept-Language' => [
'en-US' => 'en',
'ja-JP' => 'ja'
]
];
// $available support 'Accept' and 'Accept-Language' key only
$this->install(new AcceptModule($available));
}
}
use use BEAR\Accept\Annotation\Produces;
/**
* @Produces({"application/json", "text/csv"})
*/
public function onGet()