PHPackages                             tobento/service-requester - 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. tobento/service-requester

ActiveLibrary

tobento/service-requester
=========================

A PSR-7 server request wrapper class providing simplified methods.

2.0(7mo ago)01923MITPHPPHP &gt;=8.4

Since Feb 1Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/tobento-ch/service-requester)[ Packagist](https://packagist.org/packages/tobento/service-requester)[ Docs](https://www.tobento.ch)[ RSS](/packages/tobento-service-requester/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (6)Used By (3)

Requester Service
=================

[](#requester-service)

A PSR-7 server request wrapper class providing simplified methods.

Table of Contents
-----------------

[](#table-of-contents)

- [Getting started](#getting-started)
    - [Requirements](#requirements)
    - [Highlights](#highlights)
- [Documentation](#documentation)
    - [Create Requester](#create-requester)
    - [Available Methods](#available-methods)
- [Credits](#credits)

---

Getting started
===============

[](#getting-started)

Add the latest version of the requester service project running this command.

```
composer require tobento/service-requester

```

Requirements
------------

[](#requirements)

- PHP 8.4 or greater

Highlights
----------

[](#highlights)

- Framework-agnostic, will work with any project
- Decoupled design

Documentation
=============

[](#documentation)

Create Requester
----------------

[](#create-requester)

```
use Tobento\Service\Requester\Requester;
use Tobento\Service\Requester\RequesterInterface;
use Nyholm\Psr7\Factory\Psr17Factory;

// Any PSR-7 server request
$serverRequest = new Psr17Factory()->createServerRequest(
    method: 'GET',
    uri: 'https://example.com',
);

$requester = new Requester($serverRequest);

var_dump($requester instanceof RequesterInterface);
// bool(true)
```

Available Methods
-----------------

[](#available-methods)

**method**

Returns the HTTP method in uppercase such as GET, POST, PUT...

```
var_dump($requester->method());
// string(3) "GET"
```

**isSecure**

Returns whether the request is secure or not.

```
var_dump($requester->isSecure());
// bool(false)
```

**isContentType**

Determine if the request is of the specified content type.

```
var_dump($requester->isContentType('application/json'));
// bool(false)
```

**isReading**

Determine if the HTTP request is a reading request which is the case if the method is one of HEAD, GET and OPTIONS.

```
var_dump($requester->isReading());
// bool(true)
```

**isPrefetch**

Determine if the HTTP request is a prefetch call.

```
var_dump($requester->isPrefetch());
// bool(false)
```

**isAjax**

Check if request was via AJAX.

```
var_dump($requester->isAjax());
// bool(false)
```

**isJson**

Determine if the request is sending JSON.

```
var_dump($requester->isJson());
// bool(false)
```

**wantsJson**

Determine if the request is asking for JSON.

```
var_dump($requester->wantsJson());
// bool(false)
```

**json**

Returns the request JSON payload.
Check out the [Collection Service](https://github.com/tobento-ch/service-collection#collection) to learn more about the Collection in general.

```
use Tobento\Service\Collection\Collection;

var_dump($requester->json() instanceof Collection);
// bool(true)
```

**input**

Returns the request input data. Depending on the content type and method, it returns the parsed body data or the query params.
Check out the [Collection Service](https://github.com/tobento-ch/service-collection#collection) to learn more about the Collection in general.

```
use Tobento\Service\Collection\Collection;

var_dump($requester->input() instanceof Collection);
// bool(true)
```

**uri**

Returns the Uri.

```
use Psr\Http\Message\UriInterface;

var_dump($requester->uri() instanceof UriInterface);
// bool(true)
```

**request**

Returns the server request.

```
use Psr\Http\Message\ServerRequestInterface;

var_dump($requester->request() instanceof ServerRequestInterface);
// bool(true)
```

**acceptHeader**

Returns the accept header instance.

```
use Tobento\Service\Requester\AcceptHeader;
use Tobento\Service\Requester\AcceptHeaderItem;

var_dump($requester->acceptHeader() instanceof AcceptHeader);
// bool(true)

var_dump($requester->acceptHeader()->has('application/json'));
// bool(true)

var_dump($requester->acceptHeader()->get('application/json'));
// null|AcceptHeaderItem

// returns all items.
$items = $requester->acceptHeader()->all();

// returns the first item found or null.
$firstItem = $requester->acceptHeader()->first();

// returns true if first item is application/json, otherwise false.
$requester->acceptHeader()->firstIs('application/json');

// filter items returning a new instance.
$acceptHeader = $requester->acceptHeader()->filter(
    fn(AcceptHeaderItem $a): bool => $a->quality() > 0.5
);

// sort items returning a new instance.
$acceptHeader = $requester->acceptHeader()->sort(
    fn(AcceptHeaderItem $a, AcceptHeaderItem $b) => $b->quality()  $a->quality()
);

// sorts by highest quality returning a new instance.
$acceptHeader = $requester->acceptHeader()->sortByQuality();
```

Credits
=======

[](#credits)

- [Tobias Strub](https://www.tobento.ch)
- [All Contributors](../../contributors)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance63

Regular maintenance activity

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~267 days

Recently: every ~231 days

Total

6

Last Release

223d ago

Major Versions

1.x-dev → 2.02025-09-29

PHP version history (2 changes)1.0.0PHP &gt;=8.0

2.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/055d6a1b5c2384bb179c75ab0b55914231d898fdc4dffeb30770f81200e52206?d=identicon)[TOBENTOch](/maintainers/TOBENTOch)

---

Top Contributors

[![tobento-ch](https://avatars.githubusercontent.com/u/16684832?v=4)](https://github.com/tobento-ch "tobento-ch (12 commits)")

---

Tags

phppackagetobentoPSR-7 server request

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tobento-service-requester/health.svg)

```
[![Health](https://phpackages.com/badges/tobento-service-requester/health.svg)](https://phpackages.com/packages/tobento-service-requester)
```

PHPackages © 2026

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