微盟云开放平台的PHP项目的能力SDK,根据开放能力的元数据规范,提供一套PHP语言的能力定义,帮助开发者减少开发成本,使其可以快速的接入微盟云的开放生态。
- SPI能力定义
- Interface
- Request
- Response
- MSG能力定义
- Listener
- Message
|-- composer.json
|-- README.md
|-- LICENSE
|-- .gitignore
|-- src/ # 源码目录
| |-- Weimob/Wos/Cloud/ # Wos开放能力
| |-- Spi/ # SPI能力定义
| |-- Msg/ # MSG能力定义
| |-- Weimob/Xinyun/Cloud/ # Xinyun开放能力
| |-- Spi/ # SPI能力定义
| |-- Msg/ # MSG能力定义
-
使用composer管理包,在php项目工程的composer.json添加依赖
"require": { ... "weimob-cloud/php-ability-sdk": "${last_version}" }
-
安装包,使用composer命令
- composer install
- composer update
- composer dumpautoload
- composer ... 详细文档
-
Spi实现
//实现SPI的逻辑 class DemoWosSpiImpl extends BaseFramework implements PaasWeimobShopCouponPaasBatchLockCouponService { public function invoke(WeimobShopCouponPaasBatchLockCouponRequest $request): WeimobShopCouponPaasBatchLockCouponResponse { $paasResponse = new WeimobShopCouponPaasBatchLockCouponResponse(); $paasResponseCode = new PaasResponseCode(); $paasResponseCode->setErrcode("success"); $paasResponseCode->setErrmsg("success"); $data = new WeimobShopCouponPaasBatchLockCouponData(); $data->setSuccess(true); $paasResponse->setData($data); $paasResponse->setCode($paasResponseCode); return $paasResponse; } } //注册SPI实现 $spiRegistry->register("demoSpiImpl",\WeimobCloudBootDemo\Ability\Spi\Wos\DemoWosSpiImpl::class,SpecTypeEnum::WOS);
-
Msg实现
//实现消息订阅逻辑 class DemoWosMsgListerner extends BaseFramework implements WeimobCrmBalanceChangeBalanceChangeListener { public function onMessage(WeimobMessage $message) : WeimobMessageAck { $weimobMessageAck = new WeimobMessageAck(); $code = new Code(); $code->setErrcode("success"); $code->setErrmsg("成功"); $weimobMessageAck->setCode($code); return $weimobMessageAck; } } //订阅消息 $msgSubscription->subscribe(new MsgInfo("weimob_crm.balance.change","balanceChange"),\WeimobCloudBootDemo\Ability\Msg\Wos\DemoWosMsgListerner::class,SpecTypeEnum::WOS);
- 申请加入weimob_tech