PHPackages                             thvvger/symfony-request-validator - 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. thvvger/symfony-request-validator

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

thvvger/symfony-request-validator
=================================

Validate symfony request and return JSON response

1.4.9(1y ago)2152MITPHP

Since Nov 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/thvvger/symfony-request-validator)[ Packagist](https://packagist.org/packages/thvvger/symfony-request-validator)[ RSS](/packages/thvvger-symfony-request-validator/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (6)Versions (15)Used By (0)

 Table of Contents1. [About The Project](#about-the-project)
    - [Built With](#built-with)
2. [Getting Started](#getting-started)
    - [Prerequisites](#prerequisites)
    - [Installation](#installation)
3. [Usage](#usage)
4. [Roadmap](#roadmap)
5. [Contributing](#contributing)
6. [License](#license)
7. [Contact](#contact)
8. [Acknowledgments](#acknowledgments)

Symfony Request Validator
-------------------------

[](#symfony-request-validator)

`RequestValidator` is a Symfony bundle that simplifies the process of validating request data and generating request classes with validation rules. It integrates with Symfony's Validator component and provides an easy way to generate request classes with built-in validation constraints.

([back to top](#readme-top))

Getting Started
---------------

[](#getting-started)

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

### Installation

[](#installation)

1. Install the package ```
    composer require thvvger/symfony-request-validator
    ```

    2. Configure the Services : After installing the bundle, you need to register the services for the `FileGenerator` and `GenerateClassCommand`.

        Add the following configuration to your `config/services.yaml`:

        ```
        services:
        #....

           # Register FileGenerator service
           Thvvger\RequestValidator\Services\FileGenerator:
               autowire: true
               autoconfigure: true
               arguments:
                   $projectDir: '%kernel.project_dir%'  # Inject the project directory path

           # Register GenerateClassCommand as a console command
           Thvvger\RequestValidator\Command\GenerateClassCommand:
               autowire: true
               autoconfigure: true
               arguments:
                   $fileGenerator: '@Thvvger\RequestValidator\Services\FileGenerator'  # Inject the FileGenerator service
               tags:
                   - { name: 'console.command' }  # Register the command for Symfony's console
        ```

        - The `FileGenerator` service is configured with `autowire` and `autoconfigure` to automatically inject dependencies.
        - The `GenerateClassCommand` is registered as a console command, allowing you to execute it from the command line using `php bin/console generate:class`.

([back to top](#readme-top))

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

[](#configuration)

Ensure that the bundle is registered in `config/bundles.php:

```
    return [
        Thvvger\RequestValidator\RequestValidatorBundle::class => ['all' => true],
    ];
```

([back to top](#readme-top))

Usage
-----

[](#usage)

Generate a Request Class
------------------------

[](#generate-a-request-class)

To generate a request class, use the following command:

```
  php bin/console make:request TestRequest
```

This will generate a PHP file in the src/Request/ directory with a base structure for your request class.

Example Generated Class
-----------------------

[](#example-generated-class)

Here’s an example of a class generated after running the command:

```
    namespace App\Request;

    use Symfony\Component\Validator\Constraints\NotBlank;
    use Symfony\Component\Validator\Constraints\Type;
    use Thvvger\RequestValidator\BaseRequest;

    class TestRequest extends BaseRequest
    {
        #[NotBlank]
        #[Type('string')]
        public readonly string $name;

        // add other properties
    }
```

Example Usage in Your Controller
--------------------------------

[](#example-usage-in-your-controller)

After generating the `TestRequest` class with the relevant validation logic, you can use it within a controller to handle incoming requests, perform validation, and execute any necessary logic (such as file generation).

```
    #[Route('/test', methods: ['POST'])]
    public function test(TestRequest $request): JsonResponse
    {
        //...

        // Return a success message after the request is processed
        return new JsonResponse([
            'message' => 'Request exécuted succesfully',
        ]);
    }
```

If validation fails (e.g., missing or invalid file), a response like the following will be returned:

```
{
   "message": "Validation error",
   "errors": {
      "fichier": "This value is invalid",
      "someProperty": "This value cannot be blank."
   }
}
```

([back to top](#readme-top))

Contributing
------------

[](#contributing)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

([back to top](#readme-top))

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE.txt` for more information.

([back to top](#readme-top))

Contact
-------

[](#contact)

Larry-Bill ADJE - [@twitter\_handle](https://twitter.com/thvvger) -

([back to top](#readme-top))

Acknowledgments
---------------

[](#acknowledgments)

- Orphé Bobby
- Massoud FATAOU

([back to top](#readme-top))

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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

Total

14

Last Release

583d ago

Major Versions

0.1.1 → 1.02024-11-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/a41540191dfdd4976d3c62ef208e5efa817a7ed8a146e2e9e7ad61877afaaa58?d=identicon)[thvvger](/maintainers/thvvger)

---

Top Contributors

[![thvvger](https://avatars.githubusercontent.com/u/85484845?v=4)](https://github.com/thvvger "thvvger (26 commits)")

### Embed Badge

![Health badge](/badges/thvvger-symfony-request-validator/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[shopware/storefront

Storefront for Shopware

674.4M208](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M514](/packages/shopware-core)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[open-dxp/opendxp

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

9317.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

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