Record a New Relic deployment using Guzzle 7
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
$appId = getenv('NEWRELIC_APP_ID');
$apiKey = getenv('NEWRELIC_X_API_KEY');
$client = new Client();
$headers = [
'x-api-key' => $apiKey,
'Content-Type' => 'application/json',
];
$revision = date("Y-m-d h:i:sa");
$body = "{
"deployment": {
"revision": "{$revision}"
}
}";
$request = new Request(
'POST',
"https://api.newrelic.com/v2/applications/$appId/deployments.json",
// For EU region use:
// "https://api.eu.newrelic.com/v2/applications/{$appId}/deployments.json",
$headers,
$body
);
$res = $client->sendAsync($request)->wait();
$responseBody = json_decode($res->getBody(), TRUE);
if (!empty($responseBody['deployment']['id'])) {
// OK.
}
else {
// NOT OK.
}
Official docs at Recording deployments using a PHP script