ph-ash / client-php
This package is abandoned and no longer maintained.
No replacement package was suggested.
Client library for pushing data to a Phash instance
v1.1.1
2020-03-13 14:42 UTC
Requires
- php: >=7.1.0
- ext-json: *
- guzzlehttp/guzzle: ^6.5
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
This package is auto-updated.
Last update: 2023-04-13 22:23:23 UTC
README
Client library for pushing data to a Phash instance
It is designed to use either a PSR-7/PSR-17/PSR-18 compatible library or Guzzle.
Configuration
Symfony
Add a service definition with the configuration to your application.
- PSR version:
_defaults: autowire: true Phash\Client: class: Phash\ClientPSR arguments: $baseUri: "http://localhost" $apiToken: "someToken"
- Guzzle version:
_defaults: autowire: true GuzzleHttp\Client: class: GuzzleHttp\Client arguments: $config: base_uri: "http://localhost" Phash\Client: class: Phash\ClientGuzzle arguments: $apiToken: "someToken"
Plain PHP
Instantiate the client class and pass the configuration as parameters:
- PSR version:
$requestFactory = ...; // instanceof Psr\Http\Message\RequestFactoryInterface $uriFactory = ...; // instanceof Psr\Http\Message\UriFactoryInterface $streamFactory = ...; // instanceof Psr\Http\Message\StreamFactoryInterface $client = ...; // instanceof Psr\Http\Client\ClientInterface $client = new Phash\ClientPSR('http://localhost', 'someToken', $requestFactory, $uriFactory, $streamFactory, $client);
- Guzzle version:
$guzzleClient = new GuzzleHttp\Client(['base_uri' => 'http://localhost']); $client = new Phash\ClientGuzzle('someToken', $guzzleClient);
Usage
- Create a DTO (see the payload documentation):
$data = new Phash\MonitoringData( 'monitoring id', Phash\MonitoringData::STATUS_OK, 'this detail message will be displayed if a tile is clicked by a user', 60, 1, new \DateTimeImmutable(), 'path.for.tree' // can be `null` for a flat display ); // optional data $data->setTileExpansionIntervalCount(2); $data->setTileExpansionGrowthExpression('+ 4');
- Push data to the server:
$client->push($data);