mirror of
https://codeberg.org/reflect/reflect-client-php.git
synced 2025-09-13 17:43:42 +02:00
feat(doc): update readme
This commit is contained in:
parent
6e59c34f0e
commit
7470acfc9b
1 changed files with 8 additions and 8 deletions
16
README.md
16
README.md
|
@ -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]
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue