承接 orus-io/php-xbus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

orus-io/php-xbus

Composer 安装命令:

composer require orus-io/php-xbus

包简介

PHP Client for xbus.io.

README 文档

README

A PHP client for Xbus.

This client relies on the xbus-http gateway, and is limited to implementing emitters, consumers and workers.

Installation

composer require orus-io/php-xbus dev-default

Usage

Emit a message

To emit a simple envelope with one events containing one or more items:

<?php
$actor = new \XbusClient\Actor('http://test.test', 'emittername', 'theApiKey');
$actor->emitItems("a.event.type", "item1", "item2");
?>

Receive a message

Receiving messages rely on the webhook feature of xbus-http. The client application must provide a http endpoint, on which xbus-http will POST some data.

A typical implementation for the endpoint is:

<?php
$actor = new \XbusClient\Actor('http://test.test', 'consumername', 'theApiKey');
$actor->handleRequest(
    $_SERVER['HTTP_CONTENT_TYPE'],  // <- The incoming request content type
    fopen('php://input', 'r'),  // <- The incoming request body (as a resource)
    'header',  // <- a callable that set a header on the response
    'http_response_code',  // <- a callable that sets the http response code
    fopen('php://output', 'w'), // The response body resource

    // The user-defined handler. This example one will print the incoming items
    function(\Xbus\ActorProcessRequest $request): ?\Xbus\ActorProcessingState {
        foreach($request->getInputs() as $input) {
            print "input: " . $input.getName();
            foreach($input->getEnvelope()->getEvents() as $event) {
                print "event: " . $event.getType();
                foreach($event->getItems() as $item) {
                    print "item: " . $item;
                }
            };
        };
    }
);
?>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固