Method

Every HTTP request has a method (e.g. GET or POST). You can obtain the current HTTP request method via the Slimapplication’s request object:

  1. /**
  2. * What is the request method?
  3. * @return string (e.g. GET, POST, PUT, DELETE)
  4. */
  5. $app->request->getMethod();
  6. /**
  7. * Is this a GET request?
  8. * @return bool
  9. */
  10. $app->request->isGet();
  11. /**
  12. * Is this a POST request?
  13. * @return bool
  14. */
  15. $app->request->isPost();
  16. /**
  17. * Is this a PUT request?
  18. * @return bool
  19. */
  20. $app->request->isPut();
  21. /**
  22. * Is this a DELETE request?
  23. * @return bool
  24. */
  25. $app->request->isDelete();
  26. /**
  27. * Is this a HEAD request?
  28. * @return bool
  29. */
  30. $app->request->isHead();
  31. /**
  32. * Is this a OPTIONS request?
  33. * @return bool
  34. */
  35. $app->request->isOptions();
  36. /**
  37. * Is this a PATCH request?
  38. * @return bool
  39. */
  40. $app->request->isPatch();
  41. /**
  42. * Is this a XHR/AJAX request?
  43. * @return bool
  44. */
  45. $app->request->isAjax();