oploshka/rpc-core

1.0.0 2020-08-13 20:03 UTC

This package is auto-updated.

Last update: 2024-09-22 01:08:27 UTC


README

1. 安装

推荐通过 Composer 安装。运行以下命令进行安装

php composer.phar require oploshka/rpc-core

2. 特性

简洁性

  • 提供开箱即用的简单实现。

可扩展性

  • 能够编写自己的处理。
  • 可以结合自己的和内置的解决方案
  • 可以逐步覆盖。

3. 使用方法

示例代码

$MethodStorage  = new \Oploshka\Rpc\MethodStorage();

$MethodStorage->add('TestMethod1', '\\RpcMethodPath\\TestMethod1');
$MethodStorage->add('TestMethod2', '\\RpcMethodPath\\TestMethod2');

// init MultipartJsonRpc_v0_1
$rpcInitData = [
  'methodStorage'   => $MethodStorage                                           ,
  'reform'          => new \Oploshka\Reform\ReformDebug()                            ,
  'dataLoader'      => new \Oploshka\RpcDataLoader\PostMultipartFieldJson()     ,
  'dataFormatter'   => new \Oploshka\RpcDataFormatter\MultipartJsonRpc_v0_1()   ,
  'returnFormatter' => new \Oploshka\RpcReturnFormatter\MultipartJsonRpc_v0_1() ,
  'responseClass'   => new \Oploshka\Rpc\Response()                             ,
];
$Rpc = new \Oploshka\Rpc\Core($rpcInitData);
$Rpc->applyHeaderSettings();
$Rpc->applyPhpSettings();

$returnJson = $Rpc->startProcessingRequest();

echo $returnJson;

更多详情请查看文档

4. 测试

使用 PHPUnit 进行测试。代码经过测试,适用于 PHP 7.0。

5. 作者

Andrey Tyurin

6. 特别感谢

我想感谢所有认识我并支持我的人。

7. 许可证

"Rpc-core" 使用 MIT 许可证。

Copyright (c) 2018 Andrey Tyurin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.