use Illuminate\Http\Request; $request = Request::createFromGlobals(); if ($request->isMethod('post')) { // Do something if the request is a POST request }
use Illuminate\Http\Request; $request = Request::create('/foo', 'GET'); if ($request->isMethod('get')) { // Do something if the request is a GET request }In this example, we create a new Request object using the create method, which creates a new request with the specified URL and method. We then check if the request is a GET request using isMethod method. The package library used in this example is php illuminate/http.