cloudevents/sdk-php
Composer 安装命令:
composer require cloudevents/sdk-php
包简介
CloudEvents SDK
README 文档
README
Status
This SDK currently supports the following versions of CloudEvents:
Installation
Install the SDK using Composer:
composer require cloudevents/sdk-php
Create a CloudEvent
use CloudEvents\V1\CloudEvent; use CloudEvents\V1\CloudEventImmutable; // Immutable CloudEvent $immutableEvent = new CloudEventImmutable( '1n6bFxDMHZFChlI4TVI9tdzphB9', '/examples/php-sdk', 'com.example.type', ['example' => 'first-event'], 'application/json' ); // Mutable CloudEvent $mutableEvent = new CloudEvent( '1n6bFxDMHZFChlI4TVI9tdzphB9', '/examples/php-sdk', 'com.example.type', ['example' => 'first-event'], 'application/json' ); // Create immutable from mutable or via versa $event = CloudEventImmutable::createFromInterface($mutableEvent); $event = CloudEvent::createFromInterface($immutableEvent);
Serialize/Deserialize a CloudEvent
use CloudEvents\Serializers\JsonDeserializer; use CloudEvents\Serializers\JsonSerializer; // JSON serialization $payload = JsonSerializer::create()->serializeStructured($event); $payload = JsonSerializer::create()->serializeBatch($events); // JSON deserialization $event = JsonDeserializer::create()->deserializeStructured($payload); $events = JsonDeserializer::create()->deserializeBatch($payload);
Marshal/Unmarshal a CloudEvent
use CloudEvents\Http\Marshaller; use CloudEvents\Http\Unmarshaller; // Marshal HTTP request $request = Marshaller::createJsonMarshaller()->marshalStructuredRequest($event); $request = Marshaller::createJsonMarshaller()->marshalBinaryRequest($event); $request = Marshaller::createJsonMarshaller()->marshalBatchRequest($events); // Marshal HTTP response $request = Marshaller::createJsonMarshaller()->marshalStructuredResponse($event); $request = Marshaller::createJsonMarshaller()->marshalBinaryResponse($event); $request = Marshaller::createJsonMarshaller()->marshalBatchResponse($events); // Unmarshal HTTP message $events = Unmarshaller::createJsonUnmarshaller()->unmarshal($message);
Testing
You can use composer to build and run test environments when contributing.
$ composer run -l
scripts:
lint Show all current linting errors according to PSR12
lint-fix Show and fix all current linting errors according to PSR12
sa Run the static analyzer
tests Run all tests locally
tests-build Build containers to test against supported PHP versions
tests-docker Run tests within supported PHP version containers
Community
- There are bi-weekly calls immediately following the Serverless/CloudEvents call at 9am PT (US Pacific). Which means they will typically start at 10am PT, but if the other call ends early then the SDK call will start early as well. See the CloudEvents meeting minutes to determine which week will have the call.
- Slack: #cloudeventssdk channel under CNCF's Slack workspace.
- Email: https://lists.cncf.io/g/cncf-cloudevents-sdk
- Contact for additional information: Denis Makogon (
@denysmakogonon slack).
Each SDK may have its own unique processes, tooling and guidelines, common
governance related material can be found in the
CloudEvents community
directory. In particular, in there you will find information concerning
how SDK projects are
managed,
guidelines
for how PR reviews and approval, and our
Code of Conduct
information.
If there is a security concern with one of the CloudEvents specifications, or with one of the project's SDKs, please send an email to cncf-cloudevents-security@lists.cncf.io.
Additional SDK Resources
cloudevents/sdk-php 适用场景与选型建议
cloudevents/sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12M 次下载、GitHub Stars 达 96, 最近一次更新时间为 2021 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cloudevents/sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cloudevents/sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 96
- 点击次数: 9
- 依赖项目数: 12
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2021-02-23