benycode/slim-request-accept-header

There is no license information available for the latest version (v1.0.3) of this package.

Slim 4 request accept header parser

v1.0.3 2023-03-11 16:15 UTC

This package is not auto-updated.

Last update: 2024-11-03 00:17:09 UTC


README

Parse accept headers

Table of contents

Install

Via Composer

$ composer require benycode/slim-request-accept-header

Requires Slim 4.

Usage

Use DI to inject the library Middleware classes:

use Psr\Container\ContainerInterface;
use BenyCode\Slim\RequestAcceptHeader\LanguageDetectMiddleware;

return [
    ......
  LanguageDetectMiddleware::class => function (ContainerInterface $container): LanguageDetectMiddleware {
		
      return new LanguageDetectMiddleware(
        'lt', 
        ['lt', 'en'],
      );
  },
];

add a Middlewares to route globaly:

use BenyCode\Slim\RequestAcceptHeader\LanguageDetectMiddleware;

$app
  ...
  ->add(LanguageDetectMiddleware::class)
  ;
  ...

now your Slim can detect a language.