Using a Symfony application on Apache, you get null when trying to get Authorization header with $request->headers->get('Authorization');., (*1)
The why is explained in this Stackoverflow question., (*2)
So if you don't want to patch your .htaccess, this library, inspired by fschmengler's answer in this another SO question,
provides a listener which adds the Authorization header to a Symfony Request instance., (*3)
Installation
Download
Using Composer:, (*4)
``` js
{
"require": {
"alcalyn/authorization-header-fix": "1.0.x"
}
}, (*5)
### Register listener
To fix all Requests in a full stack Symfony app, register a listener like this:
``` yml
# app/config/services.yml
services:
acme.listeners.authorization_header_fix:
class: Alcalyn\AuthorizationHeaderFix\AuthorizationHeaderFixListener
tags:
- { name: kernel.event_listener, event: kernel.request, priority: 10 }
Or using Silex:, (*6)
php
$this->on('kernel.request', array(
new Alcalyn\AuthorizationHeaderFix\AuthorizationHeaderFixListener(),
'onKernelRequest'
), 10);, (*7)
Note:, (*8)
An higher priority is recommended to have the Authorization header
available in others listeners., (*9)
License
This library is under MIT License., (*10)