Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cherry-framework/request

Cherry-project Request class
https://github.com/cherry-framework/request

cherry composer request

Last synced: about 1 month ago
JSON representation

Cherry-project Request class

Awesome Lists containing this project

README

        

# cherry-Request
The Cherry-project Request wrapper

[![GitHub license](https://img.shields.io/github/license/abgeo07/cherry-request.svg)](https://github.com/ABGEO07/cherry-request/blob/master/LICENSE)

[![GitHub release](https://img.shields.io/github/release/abgeo07/cherry-request.svg)](https://github.com/ABGEO07/cherry-request/releases)

[![Packagist Version](https://img.shields.io/packagist/v/cherry-project/request.svg "Packagist Version")](https://packagist.org/packages/cherry-project/request "Packagist Version")

------------

## Including
**Install from composer** `composer require cherry-project/logger`

**Include Autoloader in your main file** (Ex.: index.php)
```php
require_once __DIR__ . '/vendor/autoload.php';
```

## Class Request
Import class
```php
use Cherry\HttpUtils\Request;
```
Crete class new object
```php
$request = new Request();
```

### Class Methods
#### getHeaders()
Get request HTTP Headers

Get all headers
```php
$allHeaders = $request->getHeaders();
```
Get single header (Ex.: Host)
```php
$singleHeader = $request->getHeaders('Host');
```
Get more then one header
```php
$manyHeaders = $request->getHeaders(['Accept', 'Accept-Encoding']);
```

##### Allowed headers
[MDN - HTTP headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers "MDN - HTTP headers")

#### getMethod()
Get request HTTP method

#### hasHeader($key)
Check if request has header

#### getPath()
Get request path(URL)

#### getScheme()
Get request scheme(http or https)

#### getQueryParams()
Get request query parameters

#### getQuery($key)
Get request query parameter by key

#### getData()
Get request data by method

**2019 © Cherry-project**