PHPackages                             liuchenrang/php-dubbo-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. liuchenrang/php-dubbo-client

ActiveLibrary[API Development](/categories/api)

liuchenrang/php-dubbo-client
============================

v1.0.4(5y ago)01.9k[1 issues](https://github.com/liuchenrang/php-dubbo-client/issues)PHP

Since Jun 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/liuchenrang/php-dubbo-client)[ Packagist](https://packagist.org/packages/liuchenrang/php-dubbo-client)[ RSS](/packages/liuchenrang-php-dubbo-client/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

php-dubbo-client
================

[](#php-dubbo-client)

php client use dubbo Hessian protocol call remote method 包含所有依赖文件php5.x php7.x 都可以运行 ， 采用hessian协议

请注意
===

[](#请注意)

本库依赖Dubbo Version2.7.(5-6),大于2.7.6由于更改参数描述过程，找不到对应方法，可以参考使用Dubbo2协议 dubbo版本是2.7.7以上版本 配置参数如下

```
//config.php
return $host = [
    'serverUser' => "slb://127.0.0.1:2100?timeout=2&dubboVersion=自己到服务端dubbo版本&version=1.0.0&port=2100&protocol=dubbo2",
];
```

```
# 本项目改自
- lornewang/idiot
- crazyxman/hessian-parser
- icecave/

```php
//config.php
return $host = [
    'serverUser' => "slb://127.0.0.1:2100?timeout=2&dubboVersion=2.7.5&version=1.0.0&port=2100&protocol=dubbo",
];
```

```
class DubboService
{
    public static $service = [];
    /**
         * @param string $fpath
         * @param int $timeout
         * @return mixed Dubbo
         */
        public static function getService($fpath = self::F_PATH_USER, $timeout = 0)
        {
            $conn = self::getConfigByServicePath($fpath);
            if (self::$service == null || empty(self::$service[$fpath])) {
                if (!empty($timeout)) {
                    $conn = self::reBuildQuery($conn, ['timeout' => $timeout]);
                }
                $urlInfo = parse_url($conn);
                parse_str($urlInfo['query'], $serverInfo);
                $serverInfo["path"] = $fpath;
                $serverInfo["conn"] = $conn;
                $serverInfo["scheme"] = $urlInfo['scheme'];
                self::$service[$fpath] = new Service($serverInfo);
            }

            return self::$service[$fpath];
        }

        /**
         * @param $url
         * @param $params (array)
         * @return string
         */
        public static function reBuildQuery($url, $params)
        {
            $get = [];
            parse_str(parse_url($url, PHP_URL_QUERY), $get);
            foreach ($params as $key => $value) {
                $get[$key] = $value;
            }
            $query = http_build_query($get);
            if (stristr($url, '?')) {
                $new_url = substr($url, 0, strrpos($url, '?'));
            } else {
                $new_url = $url;
            }
            if (empty($query)) {
                return $new_url;
            }
            return $new_url . '?' . $query;
        }

        public static function getConfigByServicePath($fpath)
        {
            $config = require("./config.php");

            if ($config[$fpath]) {
                return $config[$fpath];
            } else {
               throw new Exception("config miss");
            }
        }

}
```

```
function callWithException($func, $name="", $args){
    try {
        $res = $func();
        $result = 0;
        $data = [];
        if (is_array($res)) {
            $result = $res[0];
            $data = $res[1];
        }//正常返回

        EsLog::info("methodRpc Success $name context " . json_encode($args) . " result " . json_encode($data));
        if ($result == 1 || $result == 4) {
            return json_decode(json_encode($data), true);
        } elseif ($result == 5 || $result == 2) {
            //业务接口返回null， 找不到相关信息，或者条件不满足情况
            return [];
        } else {
            if (is_array($res) && $res[0] == 3 ){
                $d = var_export($res, true);
                throw new Exception($d);
            }
            //接口其他情况
            $message = is_array($res) || is_object($res) ? json_encode($res) : $res;
            throw new Exception($message);
        }
    } catch (Exception $e) {
        //接口其他情况
        $message = $e->getMessage();
        $connectError = "Unexpected end of stream (state: 0).";
        EsLog::error("methodRpc $name context " . json_encode($args) . " errorMsg" . $message);
        //网络超时，连不上 都会报这个， 其他到, 读超时也会触发器这个错误信息
        if ($e->getMessage() == $connectError){
            throw  new Exception("ReConnect");
        }
        throw $e;
    }
}

function getXXXX($xxx)
{
    return self::callWithException(function () use($xxx){
        $service = self::getService("com.xxx.path");
        return $service->invoke('pingMethod', [
            Type::object("com.xx.Params", [
                "xxx" => "xx"

            ], "ping")
        ]);
    }, __METHOD__,   get_defined_vars());
}
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Total

5

Last Release

1852d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ce10d2147f714ea78a7b1845a1747cdf9b6c7dbebd3120d9ec819251906785b?d=identicon)[xinghuo](/maintainers/xinghuo)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/liuchenrang-php-dubbo-client/health.svg)

```
[![Health](https://phpackages.com/badges/liuchenrang-php-dubbo-client/health.svg)](https://phpackages.com/packages/liuchenrang-php-dubbo-client)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
