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

https://github.com/webino/request

:phone: Webino™ Simple PHP environment request implementation [WIP]
https://github.com/webino/request

library request v3 webino wip

Last synced: 5 months ago
JSON representation

:phone: Webino™ Simple PHP environment request implementation [WIP]

Awesome Lists containing this project

README

          

# Webino Request

Simple PHP environment request implementation. [WIP]

[![Build Status](https://img.shields.io/travis/webino/request/master.svg?style=for-the-badge)](http://travis-ci.org/webino/request "Master Build Status")
[![Coverage Status](https://img.shields.io/coveralls/github/webino/request/master.svg?style=for-the-badge)](https://coveralls.io/github/webino/request?branch=master "Master Coverage Status")
[![Code Quality](https://img.shields.io/scrutinizer/g/webino/request/master.svg?style=for-the-badge)](https://scrutinizer-ci.com/g/webino/request/?branch=master "Master Code Quality")
[![Latest Stable Version](https://img.shields.io/github/tag/webino/request.svg?label=STABLE&style=for-the-badge)](https://packagist.org/packages/webino/request)

## Recommended Usage

Request data for application dispatch.

## Setup
[![PHP from Packagist](https://img.shields.io/packagist/php-v/webino/request.svg?style=for-the-badge)](https://php.net "Required PHP version")

```bash
composer require webino\request
```

## Quick Use

Getting request object for current execution context:
```php
use Webino\InstanceContainer;
use Webino\HttpRequest;
use Webino\ConsoleRequest;
use Webino\RequestInterface;

$container = new InstanceContainer;

/** @var RequestInterface $request */
$request = $container->get(RequestInterface::class);

if ($request instanceof HttpRequest) {

} elseif ($request instanceof ConsoleRequest) {

}
```

Making HTTP request:
```php
use Webino\InstanceContainer;
use Webino\HttpRequest;

$container = new InstanceContainer;

/** @var HttpRequest $request */
$request = $container->make(HttpRequest::class, HttpRequest::defaults([
HttpRequest::QUERY_STRING => 'foo=bar&baz=bam',
HttpRequest::SCRIPT_NAME => '/example/index.php',
HttpRequest::SCRIPT_FILENAME => '/var/www/html/example/index.php',
HttpRequest::URI => '/example/some-route'
]));
```

Making console request:
```php
use Webino\InstanceContainer;
use Webino\ConsoleRequest;

$container = new InstanceContainer;

/** @var ConsoleRequest $request */
$request = $container->make(ConsoleRequest::class, ConsoleRequest::defaults([
ConsoleRequest::COMMAND => 'foo --bar baz',
ConsoleRequest::SCRIPT_FILENAME => '/var/www/html/test/index.php',
]));
```

## API

**RequestInterface**

- *const* TIME

Request time float option.

- *const* TIME_DEFAULT

Default request time float, example value.

- *const* SCRIPT_FILENAME

Executed script file name string option.

- *const* SCRIPT_FILENAME_DEFAULT

Default executed script file name, example value.

- *float* getRequestTime()

Returns HTTP request time.

- *string* getScriptFileName()

Returns executed script file name.

**HttpRequest**

- *const* SCRIPT_NAME

Executed script name string option.

- *const* SCRIPT_NAME_DEFAULT

Executed script name, example value.

- *const* GATEWAY_INTERFACE

Gateway interface string option.

- *const* GATEWAY_INTERFACE_DEFAULT

Gateway interface, example value.

- *const* SERVER_SOFTWARE

Server software string option.

- *const* SERVER_SOFTWARE_APACHE

Apache server software, example value.

- *const* SERVER_SOFTWARE_NGINX

Nginx server software, example value.

- *const* HOST

Server host name string option.

- *const* HOST_LOCAL

Local server host name, example value.

- *const* HOST_IP

Server IP address string option.

- *const* HOST_IP_LOCAL

Local server IP address, example value.

- *const* URI

Request URI string option.

- *const* URI_DEFAULT

Request URI, example value.

- *const* METHOD

Request method string option.

- *const* METHOD_GET

GET request method, example value.

- *const* METHOD_POST

POST request method, example value.

- *const* SCHEME

Request scheme string option.

- *const* SCHEME_HTTP

HTTP request scheme, example value.

- *const* SCHEME_HTTPS

HTTPS request scheme, example value.

- *const* PORT

Request port string option.

- *const* PORT_HTTP

HTTP request port, example value.

- *const* PORT_HTTPS

HTTPS request port, example value.

- *const* QUERY_STRING

Query string option.

- *const* QUERY_STRING_DEFAULT

Query string, example value.

- *const* ACCEPT

Accept header string option.

- *const* ACCEPT_HTML

Accept HTML header, example value.

- *const* ACCEPT_LANGUAGE

Accept language header string option.

- *const* ACCEPT_LANGUAGE_DEFAULT

Default accept language, example value.

- *const* ACCEPT_CHARSET

Accept charset header string option.

- *const* ACCEPT_CHARSET_DEFAULT

Default charset header, example value.

- *const* ACCEPT_ENCODING

Accept encoding header string option.

- *const* ACCEPT_ENCODING_DEFAULT

Default accept encoding header, example value.

- *const* USER_AGENT

User agent header string option.

- *const* USER_AGENT_DEFAULT

Default user agent header, example value.

- *const* REFERER

Referer header string option.

- *const* REFERER_DEFAULT

Default referer header, example value.

- *const* REMOTE_IP

Remote IP address string option.

- *const* REMOTE_IP_LOCAL

Local remote IP address, example value.

- *const* REMOTE_PORT

Remote port string option.

- *const* REMOTE_PORT_DEFAULT

Default remote port, example value.

- *const* REQUESTED_WITH

The x-requested-with header string option.

- *const* REQUESTED_WITH_AJAX

The Ajax x-requested-with header, example value.

- *string* getRoutePath()

Returns route path.

- *string* getScriptName()

Returns executed script name.

- *string* getMethod()

Returns HTTP request method.

- *string* getHost()

Returns HTTP host name.

- *string* getHostIP()

Returns HTTP host IP address.

- *string* getScheme()

Returns HTTP request scheme.

- *bool* isHttps()

Returns true when request scheme is HTTPS.

- *string* getPort()

Returns HTTP request port.

- *string* getQueryString()

Returns HTTP request query string.

- *string* getBasePath()

Returns HTTP root.

- *string* getUri()

Returns request URI.

- *string* getGatewayInterface()

Returns server gateway interface identifier.

- *string* getServerSoftware()

Returns server software identifier.

- *string* getAccept()

Returns HTTP accept header value.

- *string* getAcceptLanguage()

Returns HTTP accept language header value.

- *string* getAcceptCharset()

Returns HTTP accept charset header value.

- *string* getAcceptEncoding()

Returns HTTP accept encoding header value.

- *string* getUserAgent()

Returns HTTP request user agent.

- *string* getReferer()

Returns HTTP referer header value.

- *string* getRemoteIP()

Returns HTTP remote IP address.

- *string* getRemotePort()

Returns HTTP remote port.

- *bool* isAjax()

Returns true when request was made by Ajax.

- *array* *static* defaults(*array* $overrides = [])

Returns default HTTP request options, example values.

**ConsoleRequest**

- *const* COMMAND

Console command string option.

- *string* getCommand()

Returns console command.

- *array* *static* defaults(*array* $overrides = [])

Returns default console request options, example values.

## Development

[![Build Status](https://img.shields.io/travis/webino/request/develop.svg?style=for-the-badge)](http://travis-ci.org/webino/request "Develop Build Status")
[![Coverage Status](https://img.shields.io/coveralls/github/webino/request/develop.svg?style=for-the-badge)](https://coveralls.io/github/webino/request?branch=develop "Develop Coverage Status")
[![Code Quality](https://img.shields.io/scrutinizer/g/webino/request/develop.svg?style=for-the-badge)](https://scrutinizer-ci.com/g/webino/request/?branch=develop "Develop Code Quality")
[![Latest Unstable Version](https://img.shields.io/github/tag-pre/webino/request.svg?label=PREVIEW&style=for-the-badge)](https://packagist.org/packages/webino/request "Packagist")

Static analysis:
```bash
composer analyse
```

Coding style check:
```bash
composer check
```

Coding style fix:
```bash
composer fix
```

Testing:
```bash
composer test
```

Git pre-commit setup:
```bash
ln -s ../../pre-commit .git/hooks/pre-commit
```

## Addendum

[![License](https://img.shields.io/packagist/l/webino/request.svg?style=for-the-badge)](https://github.com/webino/request/blob/master/LICENSE.md "BSD-3-Clause License")
[![Total Downloads](https://img.shields.io/packagist/dt/webino/request.svg?style=for-the-badge)](https://packagist.org/packages/webino/request "Packagist")
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/webino/request.svg?style=for-the-badge)

Please, if you are interested in this library report any issues and don't hesitate to contribute.
We will appreciate any contributions on development of this library.

[![GitHub issues](https://img.shields.io/github/issues/webino/request.svg?style=for-the-badge)](https://github.com/webino/request/issues)
[![GitHub forks](https://img.shields.io/github/forks/webino/request.svg?label=Fork&style=for-the-badge)](https://github.com/webino/request)