Hprose is a cross-language RPC. This project is Hprose 3.0 for PHP

Overview

Hprose

Hprose 3.0 for PHP

Build Status Join the chat at https://gitter.im/hprose/hprose-php Supported PHP versions: =7.1+ Packagist Packagist Download License

Introduction

Hprose is a High Performance Remote Object Service Engine.

It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.

Hprose supports many programming languages, for example:

  • AAuto Quicker
  • ActionScript
  • ASP
  • C++
  • Dart
  • Delphi/Free Pascal
  • dotNET(C#, Visual Basic...)
  • Golang
  • Java
  • JavaScript
  • Node.js
  • Objective-C
  • Perl
  • PHP
  • Python
  • Ruby
  • ...

Through Hprose, You can conveniently and efficiently intercommunicate between those programming languages.

This project is the implementation of Hprose for PHP.

Comments
  • 异常处理

    异常处理

    请问下使用的时候,客户端参数传输错误导致服务端异常退出,try cactch 无法捕获异常,onSendError也处理不了,请问下有什么解决方案吗

    require __DIR__.'/../vendor/autoload.php';
    use Hprose\Swoole\Server;
    function a($b, $c) {
        echo $b;
        echo  $c;
    }
    
        $server = new Server("tcp://0.0.0.0:1314");
        $server->setDebugEnabled(true);
        dump($server->isDebugEnabled());
        $server->addFunction('a');
        $server->onSendError = function ($error, \stdClass $context) {
            dump($error->getMessage());
            return true;
        };
        $server->start();
    
    
        $client = \Hprose\Client::create('tcp://127.0.0.1:1314', false);
        return $client->a(['name' => 'xz'],  new InvokeSettings(array('mode' => ResultMode::Normal)));
    
    opened by ccmyli 9
  • Adds set host support

    Adds set host support

    $client = new Client('http://192.168.1.2', false);
    $client->setHeader('Host', 'api.a.com'); // now not support
    $response = $client->someaction();
    
    opened by huangdijia 8
  • 请教一下性能的问题

    请教一下性能的问题

    最近用hprose做服务,测试程序中以前的业务逻辑不变,只是多加了hprose;

    //上面是老逻辑代码
    $hprose = new Client("tcp://0.0.0.0:1314", false);
    $hprose->test();
    

    test()方法有涉及到逻辑处理有一定性能开销的,我想知道这个new [Client()的性能开销大不大的?压测了下感觉原来的代码性能降了很多; 没加hprose: image

    加了hprose: image

    还有问下有什么技术手段,可以让这个new的Client不用频繁的实例化?1000个用户的http请求就是new1000次了,会产生1000个tcp连接,这种并发高了咋办?

    opened by forgottener 8
  • 为什么在fpm下,异步回调输出不显示,cli可以输出

    为什么在fpm下,异步回调输出不显示,cli可以输出

    //tcp服务
    require_once './src/Hprose.php';
    
    use Hprose\Socket\Server;
    
    function hello($name) {
        return "Hello $name!";
    }
    $server = new Server("tcp://127.0.0.1:1314");
    $server->addFunction('hello');
    $server->debug = true;
    $server->start();
    
    //tcp客户端
    $client = new \Hprose\Socket\Client('tcp://127.0.0.1:1314', true);
    $promise = $client->hello("abc");
    
    $promise->then(function($value) {
        var_dump($value);
        \Log::info($value);
    })->catchError(function($reason) {
        var_dump($reason);
        \Log::info($reason);
    });
    
    var_dump('??');
    

    网页输出

    image

    cli输出

    image

    opened by mrzxy 6
  • 405: Method Not Allowed

    405: Method Not Allowed

    PHP Fatal error: Uncaught Exception: 405: Method Not Allowed

    使用如下代码时,会报错,服务端使用nginx加了一个重定向wus/v1/ => public/index.php?version=v1

    $client = Client::create('http://xxxx/wus/v1/', false); $client->xxx();

    不知道怎么处理?

    opened by ycaihappy 6
  • 优化Http 客户端

    优化Http 客户端

    1、优化多个客户端同时存在,curl事件统一循环,充分利用curl 2、promise resolve之后,立马加入curl循环,完全异步化。

    比如:2个客户端,4个任务。 【客户端1】任务1需要8秒, 【客户端2】任务2需要4秒, 【客户端3】任务3依赖任务1结果需要2秒, 【客户端3】任务4依赖任务2结果需要5秒。

    原来的流程会 运行任务1->运行任务2->multi运行任务3、4。耗时:8+4+5 = 17 优化1: 运行任务1、2->multi运行任务3、4。耗时:8+5 = 13 优化2: 运行任务1、2->任务2先完成,运行任务4->任务1完成,运行任务3。耗时:8+2 = 10

    opened by pavlelee 5
  • 用了httpserver和httpclient做测试,然后报错了

    用了httpserver和httpclient做测试,然后报错了

    代码都是直接从readme里面取的,稍微调整了一下,server正常,client报错了

    server

    <?php
    require_once('hprosesrc\Hprose.php');
    
    function hello($name) {
        return 'Hello ' . $name;
    }
    
    $server = new HproseHttpServer();
    $server->addFunction('hello');
    $server->start();
    

    client

    <?php
    require_once('hprosesrc\Hprose.php');
    $client = new HproseHttpClient('http://127.0.0.1/helloserver.php');
    echo $client->hello('World');
    

    错误提示

    Object of class Hprose\Future could not be converted to string
    

    环境是windows php5.4.16

    opened by kkshow 5
  •  final fix list or map judge error

    final fix list or map judge error

    全null 随机数组长度:1001 bool(true)

    0.08392333984375毫秒 随机数组长度:10001 bool(true)

    0.092983245849609毫秒 随机数组长度:100001 bool(true)

    0.097036361694336毫秒 随机数组长度:1000001 bool(true)

    0.098943710327148毫秒

    全非null 随机数组长度:1001 bool(true)

    0.053882598876953毫秒 随机数组长度:10001 bool(true)

    0.061988830566406毫秒 随机数组长度:100001 bool(true)

    0.066041946411133毫秒 随机数组长度:1000001 bool(true)

    0.072002410888672毫秒

    opened by wklzz 4
  • 在yaf中 使用hprose 当 return 字符串时 会产生警告

    在yaf中 使用hprose 当 return 字符串时 会产生警告

    我注意到是由于 Hprose\Future 中 100行~101行 if (($value !== NULL) and is_object($value) or is_string($value)) { if (method_exists($value, 'then')) { 导致的 这是一个很棒的设计 但我觉得yaf 中的自动载入也是合理的
    能否把 or is_string($value) 去掉

    opened by pan269 4
  • Laravel 自关联的数据,在客户端无法解析

    Laravel 自关联的数据,在客户端无法解析

    如果一个方法,返回值是 一个数据对象 ModelA $a,它的一个属性 还是这个类 ModelA 构成的数据对象 $b, 那么这个返回结果在客户端就无法解析,报错为 Unexpected serialize tag '{' in stream

    实例代码如下:

    Server:

    public function testConnection()
        {
            $label = Label::find(1);
            $label->child = Label::find(2);
            return $label;
        }
    

    请问应当如何解决。

    opened by Luminee 4
  • hprose 处理 emoji 报 iconv异常

    hprose 处理 emoji 报 iconv异常

    异常栈如下

    Exception: iconv(): Detected an illegal character in input string in /home/work/app/vendor/hprose/hprose/src/Hprose/Client.php:368
    Stack trace:
    #0 /home/work/app/vendor/hprose/hprose/src/Hprose/Client.php(470): Hprose\Client->decode('Es54"iconv(): D...', Array, Object(stdClass))
    #1 /home/work/app/vendor/hprose/hprose/src/Hprose/Client.php(482): Hprose\Client->syncInvokeHandler('updateUserInfo', Array, Object(stdClass))
    #2 /home/work/app/vendor/hprose/hprose/src/Hprose/HandlerManager.php(40): Hprose\Client->invokeHandler('updateUserInfo', Array, Object(stdClass))
    #3 /home/work/app/vendor/hprose/hprose/src/Hprose/Client.php(598): Hprose\HandlerManager->Hprose\{closure}('updateUserInfo', Array, Object(stdClass))
    #4 /home/work/app/vendor/hprose/hprose/src/Hprose/Client.php(423): Hprose\Client->invoke('updateUserInfo', Array)
    #5 /home/work/app/api/modules/user/controllers/InfoController.php(205): Hprose\Client->__call('updateUserInfo', Array)
    #6 [internal function]: api\modules\user\controllers\InfoController->actionUpdate()
    #7 /home/work/app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
    #8 /home/work/app/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
    #9 /home/work/app/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('update', Array)
    #10 /home/work/app/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('user/info/updat...', Array)
    #11 /home/work/app/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
    #12 /home/work/app/api/web/index.php(16): yii\base\Application->run()
    #13 {main}
    
    opened by chenjinya 4
  • hprose能否支持stream响应,在获取数据量很大时候用

    hprose能否支持stream响应,在获取数据量很大时候用

    例如我需要获取一个很大的数据集,拿回来进行过滤、转换再保存成特定的格式。如果响应数据很大,内存会爆掉。

    目前可以使用分页解决,分割成多个小数据获取在进行合并。但逻辑会很麻烦。

    能否支持流数据响应(stream response)。 例如:guzzle stream。 https://docs.guzzlephp.org/en/stable/request-options.html#stream

    opened by hawkcraw 4
Releases(v2.0.36)
Owner
Hprose
Hprose is a High Performance Remote Object Service Engine.
Hprose
Hprose RPC 服务 in Laravel/Lumen

基于 hprose/hprose-php 开发的Laravel扩展:whereof/laravel-hprose

wangzhiqiang 6 Mar 18, 2022
A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

Motan Overview Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services. Related

Weibo R&D Open Source Projects 5.8k Dec 20, 2022
Php-rpc-server - JSON RPC server implementation for PHP.

JSON RPC Server implementation for PHP. The json-rpc is a very simple protocol. You can see this by reading the protocol specification. This library i

null 4 Sep 28, 2022
A light-weight RPC implement of google protobuf RPC framework.

sofa-pbrpc A light-weight RPC implementation of Google's protobuf RPC framework. Wiki: https://github.com/baidu/sofa-pbrpc/wiki Features High performa

Baidu 2.1k Dec 10, 2022
PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

null 464 Dec 28, 2022
A repository for showcasing my knowledge of the PHP programming language, and continuing to learn the language.

Learning PHP (programming language) I know very little about PHP. This document will list all my knowledge of the PHP programming language. Basic synt

Sean P. Myrick V19.1.7.2 2 Oct 29, 2022
Zilliqa PHP is a typed PHP-7.1+ interface to Zilliqa JSON-RPC API.

Zilliqa PHP is a typed PHP-7.1+ interface to Zilliqa JSON-RPC API. Check out the latest API documentation. Add library in a composer.json file.

Patrick Falize 6 Oct 7, 2021
Simple XML-RPC API

Readme Ripcord: Easy XML-RPC Client and Server for PHP 5 ========================================================================

Saravanakumar Arumugam 1 Nov 22, 2021
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.

TARS - A Linux Foundation Project TARS Foundation Official Website TARS Project Official Website WeChat Group: TARS01 WeChat Offical Account: TarsClou

THE TARS FOUNDATION PROJECTS 9.6k Jan 1, 2023
HLedger is cross-platform accounting software for both power users and folks new to accounting

HLedger Plain Text Accounting on Nextcloud HLedger is cross-platform accounting software for both power users and folks new to accounting. It's good f

Ryan Boder 11 Jan 20, 2022
Fresns core library: Cross-platform general-purpose multiple content forms social network service software

About Fresns Fresns is a free and open source social network service software, a general-purpose community product designed for cross-platform, and su

Fresns 82 Dec 31, 2022
Silverstripe-sspy - Python based SSPAK export with higher reliability and cross-platform compatibility

SSPY - Python Stand-alone SSPAK solution © Simon Firesphere Erkelens; Moss Mossman Cantwell Usage: sspy [create|load|extract] (db|assets) --file=my.

Simon Erkelens 1 Jun 29, 2021
Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests

PHPUnit Polyfills Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests. Requirements Instal

Yoast 147 Dec 12, 2022
All about docker projects either from dockerfile or compose. Anyway, here the project is in the form of a service, for the programming language I will make it later

Docker Project by ItsArul Hey, yo guys okay, this time I made some projects from Docker. Anyway, this project is open source, for example, if you want

Kiyo 10 Nov 4, 2022
Roach-example-project - Example project to demonstrate how to use RoachPHP in a Laravel project.

Example repository to illustrate how to use roach-php/laravel in a Laravel app. Check app/Spiders/FussballdatenSpider.php for an example spider that c

Kai Sassnowski 11 Dec 15, 2022
A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

Felix Becker 1.1k Jan 4, 2023