sjdaws / newrelic-api
PHP wrapper for New Relic API v2
This package's canonical repository appears to be gone and the package has been frozen as a result.
dev-master
2016-09-12 06:35 UTC
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ~6.0
- monolog/monolog: ~1.0
This package is not auto-updated.
Last update: 2024-01-20 15:39:41 UTC
README
Copyright (c) 2014-2015 Scott Dawson.
Documentation
Installation
The wrapper is available on Packagist (sjdaws/newrelic-api) and can be installed using Composer:
composer require sjdaws/newrelic-api
Usage
You will need an Admin or REST API key from New Relic to use the wrapper. The wrapper can either be used by instantiating endpoints directly or by instantiating a master client and accessing endpoints via chainable methods:
<?php $apiKey = 'thisisnotrealyouwillneedanapikey'; // Directly $client = new Sjdaws\NewRelicApi\Account\Users($apiKey); $users = $client->get(); // Using master client $client = new Sjdaws\NewRelicApi\Client($apiKey); $users = $client->account()->users()->get();
For the sake of simplicity the documents only use the direct method.
Debugging and Logging
For logging purposes the construct accepts a second parameter of a Monolog instance:
<?php $apiKey = 'thisisnotrealyouwillneedanapikey'; $logger = new Monolog\Logger('NewRelicApi'); $handler = new Monolog\Handler\StreamHandler('/path/to/file', Monolog\Logger::DEBUG); $logger->pushHandler($handler); $client = new Sjdaws\NewRelicApi\Account\Users($apiKey, $logger); /** * filter() will log debug messages: * - Setting filter type to 'ids', * - Setting filter value to '123,456' */ $users = $client->filter('ids', [123, 456])->get();
Endpoints
Application | Endpoint |
---|---|
Account | Usage metrics |
Account | Listing users for your account |
Application | Recording deployments |