symfony parameter passing, received parameters, method of recording Twig

Ooo, ooo, annoying, let me complete an online learning system backend and front-end integration, I So now the interface parameters (learn symfony too long), the historical record about the humiliation, after the attention, or a bunch of on-line bug, annoying

Here are some of the returned data format

The Response new new 1.return ( 
json_encode ([
"MSG" => "database stores failed ..",
"code" => 0
])
);
see, generally such action is submitted and the like, recording information MSG, code success, there is no specific data, his rendering data is generally like this:
<Input type = "hidden" value = "{{path ( 'welcome_study_update')}}" id = "post_updateMinutes"> corresponds to jump to a specified route, then the background process returns json
2.return $this->render(
"@Welcome/study_and_test/studyIndex.html.twig",
array(
"studyPageTimes" => json_encode($pageTimesAr),
)
);
Such data is typically returned, generally a indexAction, indexTwig action to the transmission request to return data rendering distal tip is typically rendered:
<Input type = "hidden" value = "{{studyPageTimes}}" id = "minutes">, meaning that the rear end of the integration time to write, direct rendering data syntax with a twig

3.return new Response("msg");    

This is usually the beginning of the action when detect if the user is not the correct type or does not specify when the client opens, return message

4. When the front end of the write address, is written using {{asset ( "url")}}

The rear end of the post receiving data, with reference to the official website, reads as follows

Finally, the body along with a request (request body) is transmitted together with the original data (raw data) can getContent()be accessed to:

1
$content = $request->getContent();

For example, this is useful when dealing with a "of [HTTP POST method is used] sent to the remote service program" JSON string.

Specific Use: 

$ Content = $ request-> getContent (); // data acquired json
$ id = $ content [ 'param_name '] // post acquired parameter, GET may be obtained in this manner, but most direct $ request-> get ( "param_name")








Guess you like

Origin www.cnblogs.com/eenio/p/11256951.html