PHPackages                             sivka/request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. sivka/request

ActiveLibrary[HTTP &amp; Networking](/categories/http)

sivka/request
=============

v1.0.2(7y ago)022MITPHP

Since Feb 10Pushed 7y agoCompare

[ Source](https://github.com/alexSivka/request)[ Packagist](https://packagist.org/packages/sivka/request)[ RSS](/packages/sivka-request/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Simple http request library
===========================

[](#simple-http-request-library)

This library provides simple way to access for request data.

Installation
------------

[](#installation)

```
composer require sivka/request

```

Table of contents
-----------------

[](#table-of-contents)

- [Example](#example)
- [Available methods](#available-methods)
- [Methods of request object](#methods-of-request-object)
    - [set](#set)
    - [int](#int)
    - [string](#string)
    - [get](#get)
    - [count](#count)
    - [toJson](#tojson)
    - [toArray](#toarray)
    - [delete](#delete)
    - [has](#has)
    - [keys](#keys)
- [License](#license)

Example
-------

[](#example)

```
// $_POST = ['id' => 1, 'name' => 'Valera']
use Sivka\Request;

echo Request::post('name'); // Valera

$post = Request::post();

echo $post->name; // Valera

echo $post->not_defined_var; // NULL
```

Available methods
-----------------

[](#available-methods)

```
Request::get(); // $_GET
Request::post(); // $_POST
Request::files(); // $_FILES
Request::session(); // $_SESSION
Request::cookie(); // $_COOKIE
Request::server(); // $_SERVER
Request::headers(); // http headers
```

All methods has same signature. Every method returns request object. If method called with argument, it returns value of specified key or NULL if key does not exists.

Methods of request object
-------------------------

[](#methods-of-request-object)

### set

[](#set)

Sets value for specified key

```
$post = Request::post();
$post->set('id', 2);
// or directly
$post->id = 2;

// array maybe used
$newData = ['surname' => 'Smith', 'age' => 33];
$post->set($newData);
```

### int

[](#int)

Returns value converted to integer or 0

```
echo $post->int('id'); // 2
```

### string

[](#string)

Returns value converted to string or empty string

```
echo $post->string('id'); // '2'
```

### get

[](#get)

Returns value if exists or null.

```
echo $post->get('id'); // 2
// or simply
echo $post->id; // 2
```

Methods `int`, `string` and `get` has second optional argument specified default value if key does not exists in request object

```
echo $post->get('notDefined', 'define_me'); // define_me
```

### count

[](#count)

Returns count of values

```
$post->count();
```

### toJson

[](#tojson)

Returns json representation of request object

```
$post->toJson();
```

### toArray

[](#toarray)

Returns request object as array

```
$post->toArray();
```

### delete

[](#delete)

Delete key from request object

```
$post->delete('id');
```

### has

[](#has)

Check if key exists in request object

```
echo $post->has('name'); // true
```

### keys

[](#keys)

Returns array of keys from request object

```
$post->keys();
```

What's profit of this? No need to use such construction:

```
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
```

License
-------

[](#license)

This project is licensed under the [MIT License](LICENSE.md)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Total

3

Last Release

2656d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32399997?v=4)[Alex](/maintainers/alexSivka)[@alexSivka](https://github.com/alexSivka)

---

Top Contributors

[![alex-sivka](https://avatars.githubusercontent.com/u/30624922?v=4)](https://github.com/alex-sivka "alex-sivka (5 commits)")[![alexSivka](https://avatars.githubusercontent.com/u/32399997?v=4)](https://github.com/alexSivka "alexSivka (3 commits)")

### Embed Badge

![Health badge](/badges/sivka-request/health.svg)

```
[![Health](https://phpackages.com/badges/sivka-request/health.svg)](https://phpackages.com/packages/sivka-request)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M81](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M85](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
