schnittstabil/harmonizer

Harmonize PHP module, CGI and FCGI/FastCGI environments by infering missing $_SERVER variables like REMOTE_USER and HTTP_AUTHORIZATION.

4.0.1 2016-04-08 15:43 UTC

This package is auto-updated.

Last update: 2024-10-26 02:20:16 UTC


README

SensioLabsInsight

Harmonize PHP module, CGI and FCGI/FastCGI environments by infering missing $_SERVER variables like REMOTE_USER and HTTP_AUTHORIZATION.

Install

$ composer require schnittstabil/harmonizer

Usage

require __DIR__.'/vendor/autoload.php';

\Schnittstabil\Harmonizer\harmonize($_SERVER);

echo 'Hello '.$_SERVER['REMOTE_USER'];

API

Schnittstabil\Harmonizer\harmonize(&$server)

Infering missing variables in $server:

\Schnittstabil\Harmonizer\harmonize($_SERVER);

// $_SERVER['.*'] from $_SERVER['REDIRECT_.*'], eg.
$_SERVER['HTTP_AUTHORIZATION']  // from $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
$_SERVER['GEOIP_LATITUDE']      // from $_SERVER['REDIRECT_REDIRECT_GEOIP_LATITUDE'];

// unify user variables, if needed
$_SERVER['REMOTE_USER']   // from $_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_USER'] // from $_SERVER['REMOTE_USER']

// from $_SERVER['HTTP_AUTHORIZATION']:
$_SERVER['AUTH_TYPE']       // 'Basic' or 'Digest'
$_SERVER['REMOTE_USER']     // if needed
$_SERVER['PHP_AUTH_USER']   // if needed
$_SERVER['PHP_AUTH_PW']     // if $_SERVER['AUTH_TYPE'] === 'Basic'
$_SERVER['PHP_AUTH_DIGEST'] // if $_SERVER['AUTH_TYPE'] === 'Digest'

License

MIT © Michael Mayer