Skip to content

Commit 6c90f34

Browse files
committed
Basic usage example for
1 parent 83935d5 commit 6c90f34

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,37 @@
77
[![License](https://poser.pugx.org/api-clients/supervisord/license.png)](https://packagist.org/packages/api-clients/supervisord)
88
[![PHP 7 ready](http://php7ready.timesplinter.ch/php-api-clients/supervisord/badge.svg)](https://travis-ci.org/php-api-clients/supervisord)
99

10+
# Install
11+
12+
To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.
13+
14+
```
15+
composer require api-clients/supervisord
16+
```
17+
18+
# Usage
19+
20+
The client needs two things, an IP + port to connect to, and the ReactPHP event loop. Once you created the client you can call the `state` method to get supervisord's current state.
21+
22+
```php
23+
use ApiClients\Client\Supervisord\AsyncClient;
24+
use ApiClients\Client\Supervisord\Resource\StateInterface;
25+
use React\EventLoop\Factory;
26+
use function ApiClients\Foundation\resource_pretty_print;
27+
28+
$loop = Factory::create();
29+
$client = AsyncClient::create('127.0.0.1:9005', $loop); // My supvervisor runs at 127.0.0.1:9005 changes for your HTTP IP + port
30+
31+
$client->state()->done(function (StateInterface $state) {
32+
resource_pretty_print($state);
33+
});
34+
35+
$loop->run();
36+
37+
```
38+
39+
For more examples check the [examples](examples) directory.
40+
1041
# License
1142

1243
The MIT License (MIT)

0 commit comments

Comments
 (0)