PHP code example of evyex / symfony-extender

1. Go to this page and download the library: Download evyex/symfony-extender 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/ */

    

evyex / symfony-extender example snippets


return [
    // ...
    Evyex\SymfonyExtender\SymfonyExtenderBundle::class => ['all' => true],
];

use Evyex\SymfonyExtender\Validator\PhoneNumber;

class UserDTO
{
    #[PhoneNumber(message: 'Please provide a valid phone number.')]
    public string $phone;
}

// Override pattern for this field only, keeping global clean_string setting
#[PhoneNumber(pattern: '/^\+380[0-9]{9}$/')]
public string $ukrainianPhone;

use Evyex\SymfonyExtender\ValueResolver\MapEntityCollection\MapEntityCollection;
use App\Entity\Product;
use Doctrine\ORM\Tools\Pagination\Paginator;

#[Route('/products', methods: ['GET'])]
public function list(
    #[MapEntityCollection(
        class: Product::class,
        defaultOrdering: ['createdAt' => MapEntityCollection::ORDERING_DESC],
        fetchAssociation: ['category', 'images'],
    )]
    Paginator $products
): Response {
    // ...
}