PHP code example of sigep / request

1. Go to this page and download the library: Download sigep/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/ */

    

sigep / request example snippets


$Request = new \Sigep\Request\Request;
$Request->paginate(); // returns a boolean

$Request->page(); // returns a integer

$Request->offset(); // returns a integer

$Request->setDefaultOffset(100); // set the default to 100

$Request->embed(); // return a array

// GET /cities?sort=state,name
$sort = $Request->sort();

/**
$sort will be similar to:
array (
    'state' => 'ASC',
    'name' => 'ASC',
)
**/

$Request->search(); // return a string

$filters = $Request->filter();
/**
GET /user?gender=female
$filters = array (
    'gender' => array (
        '=' => 'female',
    )
);

GET /user?age=+20&gender=female
$filters = array (
    'age' => array ('>' => array ('20')),
    'female' => array ('=' => array (0 => 'female')),
);

GET /users?age=20;30
$filters = array (
    'age' => array (
        '=' => array('20', '30'),
    )
);

GET /user?gender=female
GET /user?age=>20&gender=female
GET /user?age=>20,<30
GET /users?age=20>,30<
GET /users?age=20;30