Request::getMethod PHP Method

getMethod() public static method

If the X-HTTP-Method-Override header is set, and if the method is a POST, then it is used to determine the "real" intended HTTP method. The _method request parameter can also be used to determine the HTTP method, but only if enableHttpMethodParameterOverride() has been called. The method is always an uppercased string.
See also: getRealMethod()
public static getMethod ( ) : string
return string The request method
        public static function getMethod()
        {
            //Method inherited from \Symfony\Component\HttpFoundation\Request
            return \Illuminate\Http\Request::getMethod();
        }

Usage Example

Example #1
0
 public static function run(Request $request)
 {
     /** get the Controller, Method, Arguments/Parameters and the URL of the Controller */
     $controller = $request->getController() . "Controller";
     $method = $request->getMethod();
     $args = $request->getArgs();
     $controllerUrl = ROOT . "controllers" . DS . $controller . ".php";
     if ($method == "index.php") {
         $method = "index";
     }
     /** if the Controller exists, call the Controller */
     if (is_readable($controllerUrl)) {
         require_once $controllerUrl;
         $fullController = "Controllers\\" . $controller;
         $controller = new $fullController();
         if (!isset($args)) {
             $data = call_user_func(array($controller, $method));
         } else {
             $data = call_user_func_array(array($controller, $method), $args);
         }
     }
     /** Render view */
     $controllerUrl = ROOT . "views" . DS . $request->getController() . DS . $request->getMethod() . ".php";
     if (is_readable($controllerUrl)) {
         require_once $controllerUrl;
     } else {
         print "No se encontrĂ³ la ruta especificada.";
     }
 }
All Usage Examples Of Request::getMethod