PHP code example of cse / helpers-request

1. Go to this page and download the library: Download cse/helpers-request library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cse / helpers-request example snippets


switch(true) {
    case Request::isAjax():
    case Request::isPost():
        Request::post('example', 5);
        break;
    case Request::isGet():
        Request::getRequestUri();
        break;
}

$_POST['example'] = 12345;
Request::post('example');
// 12345

Request::post('example_2', 12345);
// 12345

$_GET['example'] = 12345;
Request::get('example');
// 12345

Request::get('example_2', 12345);
// 12345

$_REQUEST['example'] = 12345;
Request::request('example');
// 12345

Request::request('example_2', 12345);
// 12345

$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest';
Request::isAjax();
// true

$_SERVER['REQUEST_METHOD'] = Request::METHOD_POST;
Request::isPost();
// true

$_SERVER['REQUEST_METHOD'] = Request::METHOD_GET;
Request::isGet();
// true

$_SERVER['HTTP_REFERER'] = '/link/example';
Request::getRequestUri();
// /link/example

Request::getRequestUri('/link/home');
// /link/home

$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest';
$_SERVER['REQUEST_URI'] = '/link/example_ajax';
Request::getRequestUri();
// /link/example_ajax

Request::isRedirectedToHttps('http://google.com');
// true
bash
phpunit PATH/TO/PROJECT/tests/
bash
phpunit --configuration PATH/TO/PROJECT/phpunit.xml