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 3d 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 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

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

2609d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7dc958a70db32d72289e88ededd1374bf3e9a6da7f9fc5afcb55236a20961363?d=identicon)[alexSivka](/maintainers/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

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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