public function executeMyAction(sfWebRequest $request) { $method = $request->getMethod(); if ($method == 'GET') { // do something for GET requests } else if ($method == 'POST') { // do something for POST requests } }
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $method = $request->getMethod(); if ($method == 'GET') { // do something for GET requests } else if ($method == 'POST') { // do something for POST requests }In this example, the Symfony\Component\HttpFoundation\Request class is used to create a new request object from the global variables. The getMethod method is then called to retrieve the HTTP method used in the request. The method is then used to determine what action should be taken based on the type of request. The sfWebRequest getMethod method is part of the Symfony HTTP foundation component, which is included in the Symfony framework.