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
Requires (Dev)
- codeclimate/php-test-reporter: ^0.3.0
- fabpot/php-cs-fixer: ^1.10
- halleck45/phpmetrics: ^1.8
- pdepend/pdepend: dev-fix-namespaced-consts-and-functions as 2.0
- phpmd/phpmd: ^2.3
- satooshi/php-coveralls: ^1.0
- schnittstabil/sugared-phpunit: ^0.2.0
- squizlabs/php_codesniffer: ^2.5
README
Harmonize PHP module, CGI and FCGI/FastCGI environments by infering missing
$_SERVER
variables likeREMOTE_USER
andHTTP_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