juwai/laravel-http-rpc

Laravel package for http rpc client

1.0.0 2019-05-08 09:41 UTC

This package is auto-updated.

Last update: 2024-04-08 21:18:20 UTC


README

This package provides an easy way of connecting to HTTP RPC.

Installation

  1. Add facade and providers to config/app.php

    'aliases' => [
        ...
        'HTTPRPC' => Juwai\LaravelHTTPRPC\Facades\HTTPRPC::class,
    ],
    'providers' => [
        ...
        Juwai\LaravelHTTPRPC\Providers\HTTPRPCClientProvider::class,
    ],
  2. Publish config file:

    $ php artisan vendor:publish
  3. Add real service configuration to the published config file config/httprpc.php.

Usage

GET method

$client = HTTPRPC::get('service_one', '1.0');
$response = $client->service_function($param1, $param2);

POST method

$client = HTTPRPC::get('service_one', '1.0', 2000, 'POST');
$response = $client->service_function(['param1' => $param1, 'param2' => $param2]);

Connection monitor

If you installed Debugbar the RPC connection information shows on Debugbar panels.