Skip to content

Commit 7d16cc8

Browse files
committed
Prepare for version 1.
Move Files up to src directory level. Move evenement and ndjson-react to suggest optional packages Add README for simple usage.
1 parent 8846af5 commit 7d16cc8

File tree

8 files changed

+40
-5
lines changed

8 files changed

+40
-5
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 lucasnetau
3+
Copyright (c) 2019 EdgeTelemetrics Pty Ltd
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# JSON RPC Helper Libraries for PHP
2+
3+
This library contains classes to construct JSON RPC notification, request, response and error objects.
4+
5+
Additionally there is a ReactPHP stream decoder included which will process JSON RPC request and responses encoded via NDJSON.
6+
7+
# Quickstart
8+
9+
## Create a Request on the client
10+
```php
11+
<?php
12+
use EdgeTelemetrics\JSON_RPC\Request;
13+
$request = new Request('ping', [], 'requestId');
14+
15+
$packet = json_encode($request);
16+
17+
// Send $packet to Server
18+
````
19+
20+
# Server side
21+
```php
22+
<?php
23+
//Process request
24+
25+
// Create the response from the request to pre-fill ID
26+
$response = new Response::createFromRequest($request);
27+
$response->setResult('pong');
28+
29+
$packet = json_encode($response);
30+
31+
// Send $packet back to Client
32+
33+
```

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"require": {
99
"php": ">=7.2",
1010
"ext-json": "*",
11-
"evenement/evenement": "^3.0",
12-
"clue/ndjson-react": "^1.0"
11+
},
12+
"suggest": {
13+
"evenement/evenement": "Used by the React Stream Decoder to emit events",
14+
"clue/ndjson-react": "Used by the React Stream Decoder to process NDJSON input"
1315
},
1416
"require-dev": {
1517
"kelunik/fqn-check": "^0.1.3"
1618
},
1719
"autoload": {
18-
"psr-4": {"EdgeTelemetrics\\JSON_RPC\\": "src/EdgeTelemetrics/JSON_RPC"}
20+
"psr-4": {"EdgeTelemetrics\\JSON_RPC\\": "src/"}
1921
}
20-
}
22+
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)