PHPackages                             webignition/encapsulating-request-resolver-bundle - 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. webignition/encapsulating-request-resolver-bundle

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

webignition/encapsulating-request-resolver-bundle
=================================================

Symfony controller action argument resolver for types that extend Symfony\\Component\\HttpFoundation\\Request

2.0(3y ago)15.7kMITPHPPHP ^8.1

Since Dec 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/webignition/EncapsulatingRequestResolverBundle)[ Packagist](https://packagist.org/packages/webignition/encapsulating-request-resolver-bundle)[ Docs](https://github.com/webignition/encapsulating-request-resolver-bundle)[ RSS](/packages/webignition-encapsulating-request-resolver-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (9)Versions (7)Used By (0)

Encapsulating Request Resolver Bundle
=====================================

[](#encapsulating-request-resolver-bundle)

Easily inject your own request-encapsulating objects into controller actions.

Tired of injecting the current request into your controller action and then having to poke around in `$request->query` or `$request->request` for relevant data?

Ever found yourself wanting to model an inbound request in a more domain-specific manner by encapsulating the current request and calling domain-specific methods to get information about the request?

This helps you do that.

Platform requirements
---------------------

[](#platform-requirements)

- PHP `>=8.0.2`
- Symfony `5.4.* || 6.0.*`

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

[](#installation)

### Add as a composer dependency

[](#add-as-a-composer-dependency)

```
composer require webignition/encapsulating-request-resolver-bundle
```

### Register bundle (if not using Symfony Flex)

[](#register-bundle-if-not-using-symfony-flex)

```
# config/bundles.php
return [
    //...
    webignition\EncapsulatingRequestResolverBundle\EncapsulatingRequestResolverBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

Any object implementing [`EncapsulatingRequestInterface`](https://github.com/webignition/EncapsulatingRequestResolverBundle/blob/main/Model/EncapsulatingRequestInterface.php) can be injected as a controller action argument.

`EncapsulatingRequestInterface` has a single static `create()` method into which is passed the current request. You can do whatever you like with the request.

Example User Creation Scenario
------------------------------

[](#example-user-creation-scenario)

### Scenario

[](#scenario)

Consider an API endpoint for creating a user of an application. The endpoint expects a `POST` request having a payload with `email` and `password` fields. A controller will be ultimately responsible for accessing the relevant aspects of the request and making that information available to relevant services.

### Without using this bundle

[](#without-using-this-bundle)

We can inject the current request into the controller action and poke around in the request payload.

```
# src/Controller/UserController
namespace App\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class UserController
{
    public function create(Request $request): Response
    {
        $email = (string) $request->request->get('email');
        $password = (string) $request->request->get('password');

        // ... pass $email and $password to relevant services, build and return a response
    }
}
```

This is a very simplified example. In practice we may want to be checking that both `$email` and `$password` are not empty.

For more complex requests, validation of the request data prior to processing may be required. It is easy to start to get into territory where request-accessing logic is beyond the responsibilities of the controller.

Even with the more simple of examples, the controller needs to be aware of the shape of the request payload. It could be argued that even this small amount of information is beyond the responsibilities of the controller.

### Using this bundle

[](#using-this-bundle)

We can create a custom request class for handling and understanding the data present in a request to create a user. The logic for processing the Symfony request is encapsulated with the custom request class. The custom request class is injected into the controller action.

The more complex or involved your request processing logic is, the more it may make sense to keep that logic under the responsibility of its own class.

```
# src/Request/CreateUserRequest.php

namespace App\Request;

use Symfony\Component\HttpFoundation\Request;
use webignition\EncapsulatingRequestResolverBundle\Model\EncapsulatingRequestInterface;

class CreateUserRequest implements EncapsulatingRequestInterface
{
    public function __construct(private string $email, private string $password)
    {
    }

    public static function create(Request $request): CreateUserRequest
    {
        return new CreateUserRequest(
            (string) $request->request->get('email'),
            (string) $request->request->get('password')
        );
    }

    public function getEmail(): string
    {
        return $this->email;
    }

    public function getPassword(): string
    {
        return $this->password;
    }
}
```

```
# src/Controller/UserController
namespace App\Controller;

use App\Request\CreateUserRequest;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class UserController
{
    public function create(CreateUserRequest $request): Response
    {
        $email = $request->getEmail();
        $password = $request->getPassword());

        // ... pass $email and $password to relevant services, build and return a response
    }
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

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 ~49 days

Recently: every ~61 days

Total

6

Last Release

1371d ago

Major Versions

0.2 → 1.02022-01-20

1.2 → 2.02022-08-16

PHP version history (3 changes)0.1PHP &gt;=8.0.2

1.1PHP ^8.0|^8.1

2.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/278be37d1b614ef0c40b22b777663e545a1f6d69dd4f908888cbb557ad7e608f?d=identicon)[webignition](/maintainers/webignition)

---

Top Contributors

[![webignition](https://avatars.githubusercontent.com/u/76546?v=4)](https://github.com/webignition "webignition (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webignition-encapsulating-request-resolver-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/webignition-encapsulating-request-resolver-bundle/health.svg)](https://phpackages.com/packages/webignition-encapsulating-request-resolver-bundle)
```

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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