PHPackages                             dittto/symfony-custom-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. [Framework](/categories/framework)
4. /
5. dittto/symfony-custom-request

ActiveSymfony-bundle[Framework](/categories/framework)

dittto/symfony-custom-request
=============================

Allows use of custom requests in controllers

1.0.0(9y ago)310.1kMITPHP

Since Dec 10Pushed 9y agoCompare

[ Source](https://github.com/dittto/symfony-custom-request)[ Packagist](https://packagist.org/packages/dittto/symfony-custom-request)[ RSS](/packages/dittto-symfony-custom-request/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Symfony custom requests
=======================

[](#symfony-custom-requests)

What is it?
-----------

[](#what-is-it)

To help accomplish the "Thin controllers, fat models" ideal, this bundle allows you to create custom request objects that you can use for validating your input before it gets to the controller.

You can use these to make sure certain fields are set with certain dynamic values, or validate form data without having to add additional logic to your controller.

The aim is that your controller knows that it has the correct data and therefore can start working with it immediately, instead of having to double-check it's input is valid.

The new custom request object are defined via services, so can have any other services passed to them. This means your validation steps can use data-sources such as other APIs, databases, Elasticsearch, etc.

How to use it
-------------

[](#how-to-use-it)

The first step is to update your `composer.json` with `dittto/symfony-custom-request`. You may need to also specify the an entry in the `repositories` for the github repository.

After you've added and installed this bundle, you'll need to add it to the `AppKernel.php` file:

```
class AppKernel extends Kernel {
    public function registerBundles() {
        $bundles = [
            ...
            new \Dittto\CustomRequestBundle\DitttoCustomRequestBundle(),
```

Next we'll create our custom request. This is going to be a simple check that looks for a query string containing `token=allowed`. The test below is stored at `AppBundle/Request/TestRequest.php`.

```
use Dittto\CustomRequestBundle\Request\AbstractRequestType;

class TestRequest extends AbstractRequestType {
    public function validate():bool {
        return $this->getOriginalRequest()->query->get('token') === 'allowed';
    }
}
```

Update the services for our new TestRequest. The `tag` is important as this enables us to know this is a custom request and can be used as a controller parameter.

```
services:
    test_request:
        class: AppBundle\Request\TestRequest
        tags: [ { name: dittto.request } ]
```

Lastly, we need to tell our controller to use our custom request using it's parameters.

```
class DefaultController extends Controller {
    public function indexAction(TestRequest $request):Response {
        ...
    }
}
```

Filters
-------

[](#filters)

There is a filter chain available for altering how this code handles itself after the `validate()` method has been run. By default there is a filter in place that if a `GET` request fails, then a 400 exception is thrown.

You can add as many additional filters as you like to the chain to create automated responses based on certain request types.

New filters are added by creating a compatible filter (`RequestFilterInterface`) and adding a tag of `dittto.request_filter` when defining it as a service.

To make the filters run in a particular order, add a `slot` as a tag with a positive integer as it's value. These run in the order of lowest number first. If you assign 2 or more filters to the same slot, the first-assigned filter will take the slot and block any others from taking it's place.

### How to override default filters

[](#how-to-override-default-filters)

Slots in local configs seem to always install before vendor-defined configs, so you can use the following to replace the default filter.

```
services:
    override_exception_on_failed_get:
        class: Dittto\CustomRequestBundle\Request\Filter\NullFilterRequest
        tags: [ { name: dittto.request_filter, slot: 10 } ]
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community6

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

Unknown

Total

1

Last Release

3447d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1795120?v=4)[Nick Stacey](/maintainers/dittto)[@dittto](https://github.com/dittto)

---

Top Contributors

[![dittto](https://avatars.githubusercontent.com/u/1795120?v=4)](https://github.com/dittto "dittto (8 commits)")

---

Tags

controller request

### Embed Badge

![Health badge](/badges/dittto-symfony-custom-request/health.svg)

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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