PHP code example of digitalrevolution / symfony-request-validation

1. Go to this page and download the library: Download digitalrevolution/symfony-request-validation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalrevolution / symfony-request-validation example snippets


return [
    ...
    DigitalRevolution\SymfonyRequestValidation\Bundle\RequestValidationBundle::class => ['all' => true],
];

use DigitalRevolution\SymfonyRequestValidation\AbstractValidatedRequest;
use DigitalRevolution\SymfonyRequestValidation\ValidationRules;

class ExampleRequest extends AbstractValidatedRequest
{
    protected function getValidationRules(): ValidationRules
    {
        return new ValidationRules([
            'request' => [
                'productId'   => '

class ExampleController
{
    /**
     * @Route("/", name="my_example")
     */
    public function index(ExampleRequest $request): Response
    {
        return ...;
    }
}

class ExampleRequest extends AbstractValidatedRequest
{
    ...
    
    protected function handleViolations(ConstraintViolationListInterface $violationList): void
    {
        $renderer = new ViolationListRenderer($violationList);
        $this->logger->error($renderer->render());
    }
}