feat(doc): update readme

This commit is contained in:
Victor Westerlund 2023-01-18 15:51:05 +01:00 committed by GitHub
parent 6e59c34f0e
commit 7470acfc9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
# Reflect API UNIX socket client for PHP # Reflect API client for PHP
Make requests to endpoints created with the [Reflect API framework](https://github.com/victorwesterlund/reflect) running the same machine. Make requests to an API built using the Reflect API framework over HTTP or UNIX sockets. This program comes with both an extendable/instantiable class that you can integrate with existing PHP code, or as a stand-alone CLI which can be piped into other programs.
--- ---
@ -9,7 +9,7 @@ Make a request with `SocketClient->call()`. It will return the response as an ar
- The second value is the response body - The second value is the response body
```php ```php
$client = new Reflect\SocketClient("/path/to/socket"); $client = new Reflect\Client("<API URL or path to UNIX socket>");
$client->call("foo", Method::GET); // (array) [200, "bar"] $client->call("foo", Method::GET); // (array) [200, "bar"]
$client->call("foo", Method::POST, [ $client->call("foo", Method::POST, [
@ -26,7 +26,7 @@ Requires PHP 8.1 or newer, and of course an instance of the [Reflect socket serv
1. **Install with composer** 1. **Install with composer**
``` ```
composer require reflect/socket-server composer require reflect/client
``` ```
2. **Initialize the class** 2. **Initialize the class**
@ -34,7 +34,7 @@ Requires PHP 8.1 or newer, and of course an instance of the [Reflect socket serv
```php ```php
require_once "/vendor/autoload.php"; require_once "/vendor/autoload.php";
$client = new Reflect\SocketClient("/path/to/socket"); $client = new Reflect\Client("<API URL or path to UNIX socket>");
``` ```
3. **Make API request** 3. **Make API request**
@ -66,7 +66,7 @@ You can also run this from the command line with
php client <socket_file> <endpoint> <http_method> [payload] php client <socket_file> <endpoint> <http_method> [payload]
``` ```
and it will return a serialized JSON array with the same structure as described in the `SocketClient->call()` return. and it will return a serialized JSON array with the same structure as described in the `Client->call()` return.
*Example* *Example*
```sh ```sh
@ -80,12 +80,12 @@ Requires PHP CLI 8.1 or greater, and of course an instance of the [Reflect socke
1. **Clone repo** 1. **Clone repo**
``` ```
git clone https://github.com/victorwesterlund/reflect-socket-client-php git clone https://github.com/victorwesterlund/reflect-client-php
``` ```
2. **Run from command line** 2. **Run from command line**
``` ```
cd reflect-socket-client-php cd reflect-client-php
php client <socket_file> <endpoint> <http_method> [payload] php client <socket_file> <endpoint> <http_method> [payload]
``` ```