Skip to content

Latest commit

 

History

History
95 lines (68 loc) · 2.31 KB

README.md

File metadata and controls

95 lines (68 loc) · 2.31 KB

PHP Snitcher

Simple API client for Dead Man's Snitch inspired by official Ruby client

Dependency Status license

Install

Via Composer

composer require webcore/snitcher

Snitcher depends on HTTPlug HTTP client abstraction for PHP. You can read more about HTTPlug framework integration with Symfony bundle in HTTPlug docs.

Usage

Example with Guzzle HTTP client

Install dependencies:

  • Implementation of HttpClient adapter using Guzzle

    composer require php-http/guzzle6-adapter
    
  • Implementations of MessageFactory, StreamFactory and UriFactory

    composer require php-http/message
    

Create required factories:

use Http\Adapter\Guzzle6\Client;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Http\Message\StreamFactory\GuzzleStreamFactory;
use Http\Message\UriFactory\GuzzleUriFactory;

$httpClient = new Client(new GuzzleHttp\Client());
$messageFactory = new GuzzleMessageFactory();
$streamFactory = new GuzzleStreamFactory();
$uriFactory = new GuzzleUriFactory();

Create Snitcher instance:

use Webcore\Snitcher\Snitcher;
$snitcher = new Snitcher($httpClient, $messageFactory, $streamFactory, $uriFactory);

To check in for one of your snitches:

$snitcher->snitch("c2354d53d2");

You also may provide a message with the check in:

$snitcher->snitch("c2354d53d2", "Finished in 23.8 seconds.")

If error occurs one of these exceptions is thrown:

InvalidArgumentException
HttpClientException
Exception

Sample composer.json:

{
    "name": "some-user/nice-project",
    "require": {
        "webcore/snitcher": "^1.0.0",
        "php-http/guzzle6-adapter": "^1.1.1",
        "php-http/message": "^1.2.0"
    }
}

TODO

MIT license

Copyright (c) 2016, Štefan Peťovský