azjezz / http-normalizer
Normalize Http super globals
Installs: 975
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Language:Hack
Requires
- hhvm: ^4.85
- hhvm/hhvm-autoload: ^3.0
- hhvm/hsl: ^4.41
- hhvm/type-assert: ^4.1
Requires (Dev)
- hhvm/hhast: ^4.0
README
Normalize Http super globals.
Installation
This package can be install with Composer.
$ composer require azjezz/http-normalizer
Usage
Normalize
Normalize super globals :
$_GET
,$_POST
, and$_COOKIE
... etc :
$_GET = [ 'a' => ['b' => '4'], 'c' => [0 => 4, 'c' => ['s' => ['f' => [0 => '3']]]], 'b' => '3', 'foo' => [0 => 'baz', 1 => 'qux'], ]; $query = AzJezz\HttpNormalizer\normalize($_GET); /** * dict [ * "a[b]" => "4", * "c[0]" => "4", * "c[c][s][f][0]" => "3", * "b" => "3", * "foo[0]" => "baz", * "foo[1]" => "qux", * ] */
Normalize
$_FILES
super global :
$_FILES = [ 'slide-shows' => [ 'tmp_name' => [ 0 => ['slides' => [0 => 'tmpfoo', 1 => 'tmpbar']], ], 'error' => [0 => ['slides' => [0 => 0, 1 => 0]]], 'name' => [0 => ['slides' => [0 => 'foo.txt', 1 => 'bar.txt']]], 'size' => [0 => ['slides' => [0 => 123, 1 => 200]]], 'type' => [0 => ['slides' => [0 => 'text/plain', 1 => 'text/plain']]], ], ]; $files = AzJezz\HttpNormalizer\normalize_files($_FILES); /** * dict [ * "slide-shows[0][slides][0]" => shape( * 'tmp_name' => 'tmpfoo', * 'size' => 123, * 'error' => 0, * 'name' => 'foo.txt', * 'type' =>'text/plain', * ), * "slide-shows[0][slides][1]" => shape( * 'tmp_name' => 'tmpbar', * 'size' => 200, * 'error' => 0, * 'name' => 'bar.txt', * 'type' =>'text/plain', * ), * ] */
Parse
Parse http request body, query strings, cookie strings ... etc :
$input = 'a=b&c[]=4&b=3&a[b]=4&c[c][s][f][]=3&foo[]=baz&foo[]=qux'; $query = AzJezz\HttpNormalizer\parse($input); /** * vec [ * "a[b]" => "4", * "c[0]" => "4", * "c[c][s][f][0]" => "3", * "b" => "3", * "foo[0]" => "baz", * "foo[1]" => "qux", * ] */
License
The Http Normalizer Project is open-sourced software licensed under the MIT-licensed.