To perform a Guzzle DELETE request in PHP, you can follow these steps:
composer require guzzlehttp/guzzle
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
$response = $client->delete('https://example.com/api/resource/123');
Replace 'https://example.com/api/resource/123'
with the actual URL you want to send the DELETE request to.
$statusCode = $response->getStatusCode();
$body = $response->getBody();
You can use $statusCode
to check if the request was successful (e.g., $statusCode === 200
) and $body
to access the response body.
That's it! You have now performed a Guzzle DELETE request in PHP. Remember to handle any exceptions that may be thrown while sending the request.