In this paper, the abandoned Getrequest () method in Symfony2 is analyzed. Share to everyone for your reference, as follows:
When using Symfony recently, it was found in NetBeans that the Getrequest () method was abandoned:
/** * Shortcut to return the request service. * * @return Request * * @deprecated deprecated since version 2.4, to is removed in 3.0. Ask * Symfony to inject the Request object into your controller * method instead by type hinting it in the method ' s signature. */public function Getrequest () { return $this->container->get (' Request_stack ')->getcurrentrequest ();}
Google a bit, found that it should be written like this:
Use Symfony\component\httpfoundation\request;public function updateaction (Request $request) { $foo = $request- >get (' foo '); $bar = $request->get (' Bar ');}
Please use the Post method:
$foo = $request->request->get (' foo ');
Get mode using:
$foo = $request->query->get (' foo ');
More readers interested in PHP related content can view this site topic: "PHP Operations Office Document Tips summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP Object-oriented Programming tutorial", "PHP string (string) Usage summary, "Getting Started with Php+mysql database operation" and "PHP common database Operation Skills Summary"
I hope this article is helpful to you in PHP programming.