2017 © Pedro Peláez
 

library hprose-swoole

Hprose asynchronous client & standalone server based on swoole

image

hprose/hprose-swoole

Hprose asynchronous client & standalone server based on swoole

  • Monday, July 23, 2018
  • by andot
  • Repository
  • 16 Watchers
  • 119 Stars
  • 5,543 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 25 Forks
  • 2 Open issues
  • 13 Versions
  • 8 % Grown

The README.md

Hprose, (*1)

Hprose for Swoole

Build Status Supported PHP versions: 5.3 .. 7.1 Packagist Packagist Download License, (*2)

Introduction

Hprose is a High Performance Remote Object Service Engine., (*3)

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., (*4)

Hprose supports many programming languages, for example:, (*5)

  • 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., (*6)

This project is the implementation of Hprose for PHP based on swoole., (*7)

More Documents for Hprose 2.0: https://github.com/hprose/hprose-php/wiki, (*8)

Installation

Download Source Code

Download Link, (*9)

install by composer

{
    "require": {
        "hprose/hprose-swoole": "dev-master"
    }
}

Usage

You need to install swoole first. The minimum version of swoole been supported is 1.8.8., (*10)

You also need to install hprose-pecl 1.6.5+., (*11)

Server

Hprose for PHP is very easy to use., (*12)

You can create a standalone hprose http server like this:, (*13)

http_server.php, (*14)

<?php
    require_once "vendor/autoload.php";

    use Hprose\Swoole\Server;

    function hello($name) {
        return 'Hello ' . $name;
    }

    $server = new Server('http://0.0.0.0:80/');
    $server->addFunction('hello');
    $server->start();

tcp_server.php, (*15)

<?php
    require_once "vendor/autoload.php";

    use Hprose\Swoole\Server;

    function hello($name) {
        return 'Hello ' . $name;
    }

    $server = new Server('tcp://0.0.0.0:2016');
    $server->addFunction('hello');
    $server->start();

unix_server.php, (*16)

<?php
    require_once "vendor/autoload.php";

    use Hprose\Swoole\Server;

    function hello($name) {
        return 'Hello ' . $name;
    }

    $server = new Server('unix:/tmp/my.sock');
    $server->addFunction('hello');
    $server->start();

websocket_server.php, (*17)

<?php
    require_once "vendor/autoload.php";

    use Hprose\Swoole\Server;

    function hello($name) {
        return 'Hello ' . $name;
    }

    $server = new Server('ws://0.0.0.0:8000/');
    $server->addFunction('hello');
    $server->start();

The websocket server is also a http server., (*18)

Client

Then you can create a hprose client to invoke it like this:, (*19)

http_client.php, (*20)

<?php
    require_once "vendor/autoload.php";

    use Hprose\Swoole\Client;

    $client = new Client('http://127.0.0.1/');
    $client->hello('World')->then(function($result) {
        echo $result;
    }, function($e) {
        echo $e;
    });
    $client->hello('World 0', function() {
        echo "ok\r\n";
    });
    $client->hello('World 1', function($result) {
        echo $result . "\r\n";
    });
    $client->hello('World 2', function($result, $args) {
        echo $result . "\r\n";
    });
    $client->hello('World 3', function($result, $args, $error) {
        echo $result . "\r\n";
    });

tcp_client.php, (*21)

<?php
    require_once "vendor/autoload.php";

    use Hprose\Swoole\Client;

    $client = new Client('tcp://127.0.0.1:2016');
    $client->hello('World')->then(function($result) {
        echo $result;
    }, function($e) {
        echo $e;
    });
    $client->hello('World 0', function() {
        echo "ok\r\n";
    });
    $client->hello('World 1', function($result) {
        echo $result . "\r\n";
    });
    $client->hello('World 2', function($result, $args) {
        echo $result . "\r\n";
    });
    $client->hello('World 3', function($result, $args, $error) {
        echo $result . "\r\n";
    });

The result of invoking is a promise object, you can also specify the callback function after the arguments, the callback function supports 0 - 3 parameters:, (*22)

params comments
result The result is the server returned, if no result, its value is null.
arguments It is an array of arguments. if no argument, it is an empty array.
error It is an object of Exception, if no error, its value is null.

The Versions

23/07 2018

dev-master

9999999-dev http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

22/12 2016

v2.0.11

2.0.11.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

11/12 2016

v2.0.10

2.0.10.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

05/12 2016

v2.0.9

2.0.9.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

25/11 2016

v2.0.8

2.0.8.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

17/11 2016

v2.0.7

2.0.7.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

15/11 2016

v2.0.6

2.0.6.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

25/10 2016

v2.0.5

2.0.5.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

17/09 2016

v2.0.4

2.0.4.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

20/08 2016

v2.0.3

2.0.3.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

10/08 2016

v2.0.2

2.0.2.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

08/08 2016

v2.0.1

2.0.1.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform

05/08 2016

v2.0.0

2.0.0.0 http://hprose.com/

Hprose asynchronous client & standalone server based on swoole

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware service framework json library ajax http serialization webapi async web game websocket serialize jsonrpc communication html5 tcp rpc webservice socket cross-domain future protocol unix xmlrpc phprpc hprose cross-language cross-platform