How to set the Guzzle request method to PUT or DELETE in PHP?

To set the Guzzle request method to PUT or DELETE in PHP, you can use the put() or delete() method respectively. Here's an example:

use GuzzleHttp\Client; $client = new Client(); // For PUT request $response = $client->put('https://example.com/api/endpoint', [ 'json' => ['key' => 'value'], 'headers' => ['Authorization' => 'Bearer <your_token>'] ]); // For DELETE request $response = $client->delete('https://example.com/api/endpoint', [ 'headers' => ['Authorization' => 'Bearer <your_token>'] ]);

In the above example, https://example.com/api/endpoint is the URL of the API endpoint you want to make a PUT or DELETE request to.

For a PUT request, you can pass the payload data as an array to the json key in the options array. You can also set headers like Authorization by passing them in the headers array.

For a DELETE request, you can simply pass the URL and any headers you need to include.

Note: Make sure you have GuzzleHttp installed using Composer (composer require guzzlehttp/guzzle).