{"id":13462092,"url":"https://github.com/hprose/hprose-swoole","last_synced_at":"2025-10-18T10:48:09.063Z","repository":{"id":41403712,"uuid":"63750939","full_name":"hprose/hprose-swoole","owner":"hprose","description":"Hprose asynchronous client \u0026 standalone server based on swoole","archived":false,"fork":false,"pushed_at":"2019-07-04T06:18:16.000Z","size":69,"stargazers_count":181,"open_issues_count":4,"forks_count":40,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-06-07T23:53:23.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hprose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-20T04:44:46.000Z","updated_at":"2024-12-06T03:17:48.000Z","dependencies_parsed_at":"2022-09-21T11:11:54.458Z","dependency_job_id":null,"html_url":"https://github.com/hprose/hprose-swoole","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/hprose/hprose-swoole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hprose%2Fhprose-swoole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hprose%2Fhprose-swoole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hprose%2Fhprose-swoole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hprose%2Fhprose-swoole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hprose","download_url":"https://codeload.github.com/hprose/hprose-swoole/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hprose%2Fhprose-swoole/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279516934,"owners_count":26183889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-18T02:00:06.492Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T12:00:38.480Z","updated_at":"2025-10-18T10:48:09.018Z","avatar_url":"https://github.com/hprose.png","language":"PHP","funding_links":[],"categories":["Uncategorized","Server","RPC框架"],"sub_categories":["Uncategorized"],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"http://hprose.com/banner.@2x.png\" alt=\"Hprose\" title=\"Hprose\" width=\"650\" height=\"200\" /\u003e\u003c/p\u003e\n\n# Hprose for Swoole\n\n[![Build Status](https://travis-ci.org/hprose/hprose-swoole.svg?branch=master)](https://travis-ci.org/hprose/hprose-swoole)\n![Supported PHP versions: 5.3 .. 7.1](https://img.shields.io/badge/php-5.3~7.1-blue.svg)\n[![Packagist](https://img.shields.io/packagist/v/hprose/hprose-swoole.svg)](https://packagist.org/packages/hprose/hprose-swoole)\n[![Packagist Download](https://img.shields.io/packagist/dm/hprose/hprose-swoole.svg)](https://packagist.org/packages/hprose/hprose-swoole)\n[![License](https://img.shields.io/packagist/l/hprose/hprose-swoole.svg)](https://packagist.org/packages/hprose/hprose-swoole)\n\n## Introduction\n\n*Hprose* is a High Performance Remote Object Service Engine.\n\nIt 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.\n\n*Hprose* supports many programming languages, for example:\n\n* AAuto Quicker\n* ActionScript\n* ASP\n* C++\n* Dart\n* Delphi/Free Pascal\n* dotNET(C#, Visual Basic...)\n* Golang\n* Java\n* JavaScript\n* Node.js\n* Objective-C\n* Perl\n* PHP\n* Python\n* Ruby\n* ...\n\nThrough *Hprose*, You can conveniently and efficiently intercommunicate between those programming languages.\n\nThis project is the implementation of Hprose for PHP based on swoole.\n\nMore Documents for Hprose 2.0: https://github.com/hprose/hprose-php/wiki\n\n## Installation\n\n### Download Source Code\n[Download Link](https://github.com/hprose/hprose-swoole/archive/master.zip)\n\n### install by `composer`\n```javascript\n{\n    \"require\": {\n        \"hprose/hprose-swoole\": \"dev-master\"\n    }\n}\n```\n\n## Usage\n\nYou need to install [swoole](http://www.swoole.com/) first. The minimum version of [swoole](https://github.com/swoole/swoole-src) been supported is 1.8.8.\n\nYou also need to install [hprose-pecl](https://pecl.php.net/package/hprose) 1.6.5+.\n\n### Server\n\nHprose for PHP is very easy to use.\n\nYou can create a standalone hprose http server like this:\n\n`http_server.php`\n```php\n\u003c?php\n    require_once \"vendor/autoload.php\";\n\n    use Hprose\\Swoole\\Server;\n\n    function hello($name) {\n        return 'Hello ' . $name;\n    }\n\n    $server = new Server('http://0.0.0.0:80/');\n    $server-\u003eaddFunction('hello');\n    $server-\u003estart();\n```\n\n`tcp_server.php`\n```php\n\u003c?php\n    require_once \"vendor/autoload.php\";\n\n    use Hprose\\Swoole\\Server;\n\n    function hello($name) {\n        return 'Hello ' . $name;\n    }\n\n    $server = new Server('tcp://0.0.0.0:2016');\n    $server-\u003eaddFunction('hello');\n    $server-\u003estart();\n```\n\n`unix_server.php`\n```php\n\u003c?php\n    require_once \"vendor/autoload.php\";\n\n    use Hprose\\Swoole\\Server;\n\n    function hello($name) {\n        return 'Hello ' . $name;\n    }\n\n    $server = new Server('unix:/tmp/my.sock');\n    $server-\u003eaddFunction('hello');\n    $server-\u003estart();\n```\n\n`websocket_server.php`\n```php\n\u003c?php\n    require_once \"vendor/autoload.php\";\n\n    use Hprose\\Swoole\\Server;\n\n    function hello($name) {\n        return 'Hello ' . $name;\n    }\n\n    $server = new Server('ws://0.0.0.0:8000/');\n    $server-\u003eaddFunction('hello');\n    $server-\u003estart();\n```\n\nThe websocket server is also a http server.\n\n### Client\n\nThen you can create a hprose client to invoke it like this:\n\n`http_client.php`\n```php\n\u003c?php\n    require_once \"vendor/autoload.php\";\n\n    use Hprose\\Swoole\\Client;\n\n    $client = new Client('http://127.0.0.1/');\n    $client-\u003ehello('World')-\u003ethen(function($result) {\n        echo $result;\n    }, function($e) {\n        echo $e;\n    });\n    $client-\u003ehello('World 0', function() {\n        echo \"ok\\r\\n\";\n    });\n    $client-\u003ehello('World 1', function($result) {\n        echo $result . \"\\r\\n\";\n    });\n    $client-\u003ehello('World 2', function($result, $args) {\n        echo $result . \"\\r\\n\";\n    });\n    $client-\u003ehello('World 3', function($result, $args, $error) {\n        echo $result . \"\\r\\n\";\n    });\n```\n\n`tcp_client.php`\n```php\n\u003c?php\n    require_once \"vendor/autoload.php\";\n\n    use Hprose\\Swoole\\Client;\n\n    $client = new Client('tcp://127.0.0.1:2016');\n    $client-\u003ehello('World')-\u003ethen(function($result) {\n        echo $result;\n    }, function($e) {\n        echo $e;\n    });\n    $client-\u003ehello('World 0', function() {\n        echo \"ok\\r\\n\";\n    });\n    $client-\u003ehello('World 1', function($result) {\n        echo $result . \"\\r\\n\";\n    });\n    $client-\u003ehello('World 2', function($result, $args) {\n        echo $result . \"\\r\\n\";\n    });\n    $client-\u003ehello('World 3', function($result, $args, $error) {\n        echo $result . \"\\r\\n\";\n    });\n```\n\nThe result of invoking is a promise object, you can also specify the callback function after the arguments, the callback function supports 0 - 3 parameters:\n\n|params   |comments                                                           |\n|--------:|:------------------------------------------------------------------|\n|result   |The result is the server returned, if no result, its value is null.|\n|arguments|It is an array of arguments. if no argument, it is an empty array. |\n|error    |It is an object of Exception, if no error, its value is null.      |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhprose%2Fhprose-swoole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhprose%2Fhprose-swoole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhprose%2Fhprose-swoole/lists"}