Skip to content

Commit 2c29aa9

Browse files
committed
improve doc
better composer requirement usage
1 parent 5730f33 commit 2c29aa9

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# Easy-to-use Swoole WebSocket Client
2+
3+
## Installation
4+
5+
```
6+
composer require lessmore92/swoole-websocket-client
7+
```
8+
9+
## Requirements
10+
11+
* PHP>=7.4
12+
* [openswoole](https://openswoole.com/docs/get-started/installation)-4.11.1 (not tested other versions, maybe it works.)
13+
14+
## Usage
15+
16+
Just pass the web socket URL to `WebSocketClient`.
17+
18+
19+
### Note:
20+
* This library is for CLI-based scripts and does not work for web-based ones.
21+
* Because of web socket is async (and maybe be an always running task) it needs to be executed in the Swoole coroutine (`Co\run`); see sample below.
122

223
## Sample
324

@@ -14,7 +35,7 @@ run(function () {
1435
1536
while ($webSocketClient->client->connected)
1637
{
17-
$data = $webSocketClient->recv()->data;
38+
$data = $webSocketClient->recv();
1839
var_dump($data);
1940
}
2041
});

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require": {
2020
"php": "^7.4|^8.0",
21-
"psr/http-message": "1.0.x-dev"
21+
"psr/http-message": "1.0.*"
2222
},
2323
"require-dev": {
2424
"swoole/ide-helper": "@dev"

composer.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)