How can I set the content of a symfony request?

I manually create a request for the contents of my form and want to set data such as:

form[1][]=2&form[2][]=3&form[3][]=5&form[4][]=8&form[apply]= 

The Symfony Request object has a getContent() method, but does not have setContent() .

How to customize content as an alternative?

+5
source share
2 answers

Found a solution that is dirty but seems to work for me. Just reinitialize the request.

  $request->initialize( $request->query, $request->request, $request->attributes, $request->cookies, $request->files, $request->server, '<your-content>' ); 
+7
source

Another option is the Request::create method.

 Request::create( '<uri>', '<method>', <parameters>, <cookies>, <files>, <server>, '<your-content>' ); 

Source: HTTP Foundation

+2
source

Source: https://habr.com/ru/post/1202048/


All Articles