duffleman / crpc
基于 json-client 的 CRPC 实现。
1.0.0
2021-07-08 08:44 UTC
Requires
- php: >=7.0
- duffleman/json-client: ^2.0
- jawira/case-converter: ^3.4
Requires (Dev)
- symfony/var-dumper: ^3.0
This package is auto-updated.
Last update: 2024-09-26 20:35:54 UTC
README
crpc for PHP,从 billinghamj/crpc 获得灵感。
关于
JSONClient 非常酷,但这更符合 crpc 标准。
基本用法
<?php require_once 'vendor/autoload.php'; use Duffleman\crpc; // important trailing slash here $c = new crpc\crpc('https://api.avocado.cuv-nonprod.app/1/service-staff/', [ 'headers' => ['Authorization' => '... keys here'], ]); $res = $c->do('1/latest/list_staff', [ 'showPastEmployees' => true, // converted to snake case ]); foreach ($res as $staff) { $staff = (object) $staff; $staff->about = (object) $staff->about; // only because I prefer -> to array accessors if (!$staff->isActive) { // converted from snake case echo '!! '; } echo "{$staff->about->name} ({$staff->about->role})"; echo "\n"; }