Analysis of the abandoned getRequest () method in Symfony2, symfony2getrequest_PHP tutorial

Source: Internet
Author: User
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');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.