PHP code example of php-arsenal / symfony-request-param-bagger
1. Go to this page and download the library: Download php-arsenal/symfony-request-param-bagger 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/ */
php-arsenal / symfony-request-param-bagger example snippets
use PhpArsenal\SymfonyRequestParamBagger\RequestParamBagger;
// ...
#[Route('/api', methods: ['POST'], format: 'json')]
public function postSomething(
Request $request
): JsonResponse {
$params = RequestParamBagger::build($request, [
'type' => null,
'size' => null,
'amount' => null,
], [
'type' => 'string',
'size' => 'int',
'amount' => 'float',
]);
var_dump($params);
// ...
text
array(3) {
["type"]=>
string(4) "gold"
["size"]=>
int(20)
["amount"]=>
float(1.23)
}