Analysis of the abandoned getRequest () method in Symfony2, symfony2getrequest. Analysis of the abandoned getRequest () method in Symfony2. this document analyzes the abandoned getRequest () method in Symfony2. For your reference, the details are as follows: analysis of the abandoned getRequest () method in Symfony2, symfony2getrequest
This document analyzes the abandoned getRequest () method in Symfony2. We will share this with you for your reference. The details are as follows:
When Symfony was recently used, 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 be 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 found that it should be written as follows:
use Symfony\Component\HttpFoundation\Request;public function updateAction(Request $request){ $foo = $request->get('foo'); $bar = $request->get('bar');}
Use the following post method:
$foo = $request->request->get('foo');
Use the following get method:
$foo = $request->query->get('foo');