定制 pport/rpc 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pport/rpc

最新稳定版本:v1.0.2

Composer 安装命令:

composer require pport/rpc

包简介

Pport RPC Client-Server Implementation

README 文档

README

Pport RPC Package : Easily fluent remote calls to your backend.

Installation

Install pport\rpc using composer :

composer require pport/rpc

Deploy A Server and Client

1. Deploy the server : server.php

<?php

class TestRemoteClass1
{
    public static $api_data;
    public function helloWorld()
    {
        return ['attribute1' => 'TestRemoteClass1 Attribute 1', 'attribute2' => 'TestRemoteClass1 Attribute 2'];
    }
}


class TestRemoteClass2
{
    public static $api_data;
    public function fetchData()
    {
        /**return [
            'data' => ['1', '2', '3', '4']
        ];**/

        return ['1', '2', '3', '4'];
    }

    public function fetchString()
    {
        return "HelloWorld 2";
    }
}

//Run the server
Pport\Rpc\Server::run();
/**Pport\Rpc\Server::verify_request(function (){
    Pport\Rpc\Server::run();
})**/;?>

2. Connect to your server from your frontend or other interface : e.g. client.php

<?php
    $rpcClient = new Pport\Rpc\Client();
    $rpcClient->set_api_url("http://localhost/epesicloud/pport-rpc/tests/server.php");
    //Call remote class method
    $testRemoteObject1 = TestRemoteClass1::helloWorld();
    //Access returned data  attributes from the returned object/s
    echo $testRemoteObject1->attribute1;
    echo "<br/>";
    echo $testRemoteObject1->attribute2;
    echo "<br/>";
    echo "<br/>";
    //Access returned data  attributes from the returned object/s
    $testRemoteObject2 = TestRemoteClass2::fetchData();
    var_dump($testRemoteObject2);

    //Access String Data
    $fetchedString = TestRemoteClass2::fetchString();
    var_dump($fetchedString);
;?>

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2022-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固