haskel / request-param-bind-bundle
Converts HTTP request to DTO
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- symfony/yaml: ~4.0|~5.0|~6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/dependency-injection: ~5.0
- symfony/http-kernel: ~5.0
README
name=John&surname=Smith
class Controller { public function getPerson(#[FromQuery] string $name, #[FromQuery] string $surname) { //... } }
name=John&surname=Smith&middleName=Dude
class Person { public ?string $name; public ?string $surname; public ?string $middleName; } class Controller { public function getPerson(#[FromQuery] Person $person) { //... } }
filter[price][from]=10&filter[price][to]=300
class Filter { public ?PriceRange $price; } class PriceRange { public ?float $from; public ?float $to; } class Controller { public function filter(#[FromQuery] Filter $filter) { //... } }
page=3&itemsPerPage=100&filter[price][from]=10&filter[price][to]=300
class Filter { public ?PriceRange $price; } class PriceRange { public ?float $from; public ?float $to; } class Pagination { public int $page = 1; public int $itemsPerPage = 10; } class Controller { public function filter(#[FromQuery] Filter $filter, #[FromQuery] Pagination $pagination) { //... } }
filter[name][0]=location&filter[value][0]=California&filter[name][1]=maxPrice&filter[value][1]=300
class Filter { public string $name; public $value; } class Controller { public function filter(#[FromQuery] Filter ...$filters) { //... } }
Body
same as Query