PHPackages                             baiseiit/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. baiseiit/form-request-bundle

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

baiseiit/form-request-bundle
============================

An adaptation of the Laravel Form Request for Symfony

v1.0.0(3y ago)03.8k1MITPHPPHP ^7.1.3 || ^8.0

Since Feb 15Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (8)Versions (2)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 baiseiit/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 baiseiit/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 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.6% 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

1188d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d8edafc9738e7661c962d9d816904484f5823773c201bb663a38c9b2849d357?d=identicon)[Alibek](/maintainers/Alibek)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[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)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/storefront

Storefront for Shopware

684.2M148](/packages/shopware-storefront)

PHPackages © 2026

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