How to get request method in Joomla 4

21 Views Asked by At

I am wondering why such a simple thing turns compilated in Joomla 4.

I have a URL call. Inside my custom extension, I need to know the request method, GET or POST. For instance, I need to retrieve REQUEST_METHOD data in $_SERVER array. But I wasn't able.

How can I do that?

Thanks Jaime

1

There are 1 best solutions below

0
jamesgarrett On BEST ANSWER

The Input object has a getMethod method. Note the method is returned as an uppercase string.

Example usage:

use Joomla\CMS\Factory;

$app = Factory::getApplication(); 
$input = $app->input;

if($input->getMethod() == "HEAD"){return;}