romeoz / rock-request
HTTP request library for PHP
Installs: 1 583
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- romeoz/rock-base: 0.12.*
Requires (Dev)
- phpunit/phpunit: ^4.7.0
- romeoz/rock-sanitize: 0.11.*
Suggests
- romeoz/rock-sanitize: required for sanitizing http-variables
README
Features
- Sanitizing http-variables
- Standalone module/component for Rock Framework
Installation
From the Command Line:
composer require romeoz/rock-request
In your composer.json:
{ "require": { "romeoz/rock-request": "*" } }
Quick Start
use rock\request\Request; // example url: http://site.com/foo/?page=1&foo[bar]=test // returns relative URL (new Request)->getUrl(); // output: /foo/?page=1&foo[bar]=test // returns host (new Request)->getHost(); // output: site.com // returns query params (new Request)->rawGet(); // output: ['page' => 1, 'foo' => ['bar' => 'test']] // returns query params as multiple (new Request)->rawGet(['foo', 'bar']); // output: test // alternative approach (new Request)->rawGet('foo.bar'); // output: test
####Sanitize
For sanitizing http-variables required install Rock Sanitize: composer require romeoz/rock-sanitize
.
use rock\sanitize\Sanitize; // example url: http://site.com/foo/?page=<b>-1</b> // default sanitize: Sanitize::removeTags()->trim()->toType(); Request::get('page'); // output: -1 // Add custom sanitize Request::get('page', null, Sanitize::removeTags()->trim()->positive()); // output: 1
Requirements
- PHP 5.4+
- For sanitizing http-variables required Rock Sanitize:
composer require romeoz/rock-sanitize
All unbolded dependencies is optional
License
HTTP request library is open-sourced software licensed under the MIT license.