PHPackages                             adamsafr/form-request-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. adamsafr/form-request-bundle

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

adamsafr/form-request-bundle
============================

An adaptation of the Laravel Form Request for Symfony

v0.1.2(6y ago)86.0k5[3 issues](https://github.com/adamsafr/form-request-bundle/issues)MITPHPPHP ^7.1.3

Since Mar 31Pushed 5y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c3573ad9f744ddd390f9ba071c880cdaff83526bea868a91ece352f194f262b5/68747470733a2f2f7472617669732d63692e6f72672f6164616d736166722f666f726d2d726571756573742d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/adamsafr/form-request-bundle)

Form Request Bundle
===================

[](#form-request-bundle)

This bundle provides similar solution as the Laravel Form Request. Form request is custom request class that contains validation logic and it's executed (validated) before the controller action is called.

Installation
============

[](#installation)

Applications that use Symfony Flex
----------------------------------

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require adamsafr/form-request-bundle
```

Applications that don't use Symfony Flex
----------------------------------------

[](#applications-that-dont-use-symfony-flex)

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require adamsafr/form-request-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `app/AppKernel.php` file of your project:

```
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new Adamsafr\FormRequestBundle\AdamsafrFormRequestBundle(),
        ];

        // ...
    }

    // ...
}
```

Configuration
-------------

[](#configuration)

Create the `adamsafr_form_request.yaml` file in the `config/packages` directory for Symfony 4 or add it in the `app/config/config.yml` file:

```
adamsafr_form_request:
  exception_listeners:
    access_denied:
      # Sets json response of the Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
      enabled: true
    form_validation:
      # Sets json response of the Adamsafr\FormRequestBundle\Exception\FormValidationException
      enabled: true
    json_decode:
      # Sets json response of the Adamsafr\FormRequestBundle\Exception\JsonDecodeException
      enabled: true
```

Usage
-----

[](#usage)

```
// src/Request/UserRequest.php

namespace App\Request;

use Adamsafr\FormRequestBundle\Http\FormRequest;
use App\Service\Randomizer;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints as Assert;

class UserRequest extends FormRequest
{
    /**
     * @var Randomizer
     */
    private $randomizer;

    /**
     * You can inject services here
     *
     * @param Randomizer $randomizer
     */
    public function __construct(Randomizer $randomizer)
    {
        $this->randomizer = $randomizer;
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return $this->randomizer->getNumber() > 0.5;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return null|Constraint|Constraint[]
     */
    public function rules()
    {
        return new Assert\Collection([
            'fields' => [
                'email' => [
                    new Assert\NotBlank(),
                    new Assert\NotNull(),
                    new Assert\Email(),
                ],
                'firstName' => new Assert\Length(['max' => 255]),
                'lastName' => new Assert\Optional([
                    new Assert\Length(['max' => 3]),
                ]),
            ],
        ]);
    }
}
```

```
// src/Controller/ApiTestController.php

namespace App\Controller;

use App\Request\UserRequest;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class ApiTestController extends AbstractController
{
    public function index(UserRequest $form)
    {
        $email = $form->getRequest()->request->get('email');
    }
}
```

License
-------

[](#license)

It is released under the [MIT License](LICENSE.md).

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.3% 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 ~199 days

Total

3

Last Release

2294d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99aa739b4251ffdea14fb0db9780aaf55354673185d54e95c58864114ac3038f?d=identicon)[adamsafr](/maintainers/adamsafr)

---

Top Contributors

[![adamsafr](https://avatars.githubusercontent.com/u/16195344?v=4)](https://github.com/adamsafr "adamsafr (33 commits)")[![dave-redfern](https://avatars.githubusercontent.com/u/1477147?v=4)](https://github.com/dave-redfern "dave-redfern (2 commits)")

---

Tags

form-requestsymfonysymfony-bundle

### Embed Badge

![Health badge](/badges/adamsafr-form-request-bundle/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M418](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

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