PHP Classes

Many Requested: Process HTTP request parameters according to rules

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 15 All time: 11,435 This week: 41Up
Version License PHP version Categories
many-requested 1.0.0MIT/X Consortium ...7PHP 7
Description 

Author

This package can process HTTP request parameters according to rules.

It can take an array of options as a parameter and return another array with values extracted from the current HTTP request values.

Currently, it can:

- Return request parameter values like the HTTP URL parts

- Return the current locale setting according to the user browser settings

- Fix the HTTP request path removing the www. from the host and duplicated / characters

- The actual user IP address checking different HTTP request parameter values

- Get all request headers

Picture of Engin Ypsilon
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

 

Example

<?php

/**
 * $ php -S localhost:8000
 * http://localhost:8000
 * http://localhost:8000/?a&b
 */
use Many\Http\Requested;

require
dirname(__DIR__) . '/vendor/autoload.php';

/** @return String output helper **/
$print_pre = function($name, $var) {
    return
printf('<h2 style="font-size:1.2rem;">%s</h2><pre>%s</pre><hr>', $name, print_r($var, true));
};


/** @var Mixed Requested **/
$print_pre('Requested',
   
/**
     * @var Bool "$accept_locales" if true, Method returns an extended Locales array based on header("Accept-Language")
     * @var Bool "$fix_path" if true, clear the requesting path, repeatedly "/" and rediret from "www." to none "www."
     * @var Array "$locales" Optional locales settings, expected array
     * @var Array "$keep_parameter" Optional $_GET helper, expects already validated $_GET Key and value
     */
   
(new Requested)->get([
       
'accept_locales' => true,
       
'fix_path' => true,
       
'locales'=> [
           
'de' => [
               
'id' => 1,
               
'title' => 'Deutsch',
               
'iso' => 'de',
               
'is_default' => true,
            ],
        ],
       
'keep_parameter' => [
           
'get' => [
               
'a' => 'test',
               
'b' => 'parameter'
           
],
           
'separator' => '&',
        ]
    ])
);


Details

Many Requested

composer require eypsilon/many-requested

<?php
/
 * $ php -S localhost:8000
 * http://localhost:8000/?a&b
 */
use Many\Http\Requested;

require dirname(__DIR__) . '/vendor/autoload.php';

/@var Mixed Requested/
$print_pre('Requested',
    / 
     * @var Bool "$accept_locales" if true, Method returns an extended Locales array based on header("Accept-Language")
     * @var Bool "$fix_path" if true, clear the requesting path, repeatedly "/" and rediret from "www." to none "www."
     * @var Array "$locales" Optional locales settings, expected array
     * @var Array "$keep_parameter" Optional $_GET helper, expects already validated $_GET Key and value 
     */
    (new Requested)->get([
        'accept_locales' => true,
        'fix_path' => true,
        'locales'=> [
            'de' => [
                'id' => 1,
                'title' => 'Deutsch',
                'iso' => 'de',
                'is_default' => true,
            ],
        ],
        'keep_parameter' => [
            'get' => [
                'a' => 'test', 
                'b' => 'parameter'
            ],
            'separator' => '&',
        ]
    ])
);

  Files folder image Files (10)  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (1 directory)
Files folder imagetest (4 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:15
This week:0
All time:11,435
This week:41Up