-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
943 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# PHP Snitcher | ||
|
||
Simple API client for [Dead Man's Snitch](https://deadmanssnitch.com) inspired by official [Ruby client](https://github.com/deadmanssnitch/snitcher) | ||
|
||
## Install | ||
|
||
Via Composer | ||
|
||
``` | ||
composer require webcore/snitcher | ||
``` | ||
|
||
Snitcher depends on [HTTPlug](http://httplug.io/) HTTP client abstraction for PHP. | ||
You can read more about [HTTPlug framework integration with Symfony bundle](http://docs.php-http.org/en/latest/integrations/symfony-bundle.html) 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: | ||
|
||
```php | ||
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: | ||
|
||
```php | ||
use Webcore\Snitcher\Snitcher; | ||
$snitcher = new Snitcher($httpClient, $messageFactory, $streamFactory, $uriFactory); | ||
``` | ||
|
||
To check in for one of your snitches: | ||
|
||
```php | ||
$snitcher->snitch("c2354d53d2"); | ||
``` | ||
|
||
You also may provide a message with the check in: | ||
|
||
```php | ||
$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 | ||
- Client for [Dead Man's Snitch's JSON API](https://deadmanssnitch.com/docs/api/v1) | ||
- Unit tests | ||
|
||
### MIT license | ||
|
||
Copyright (c) 2016, Štefan Peťovský |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "webcore/snitcher", | ||
"description": "Simple API client for Dead Man's Snitch", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Štefan Peťovský", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Webcore\\Snitcher\\": "src/" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=5.6", | ||
"webcore/validation-traits": "^1.0", | ||
"php-http/client-implementation": "^1.0", | ||
"php-http/message-factory": "^1.0.2", | ||
"guzzlehttp/psr7": "^1.3.0" | ||
}, | ||
"suggest": { | ||
"php-http/guzzle6-adapter": "Implementation of HttpClient adapter using Guzzle", | ||
"php-http/message": "Implementations of MessageFactory, StreamFactory and UriFactory" | ||
} | ||
} |
Oops, something went wrong.