patbator/activitystreams
Composer 安装命令:
composer require patbator/activitystreams
包简介
Activity Streams is a simple specification used to describe social actions around the web. http://activitystrea.ms
README 文档
README
A PHP implementation of the Activity Streams 2.0
This library aims to provide AS2 vocabulary as php objets from json and to serialize them back in json. It does not aim to be a full JSON-LD implementation.
Install
With Composer
$ composer require patbator/activitystreams
Manually
Clone or download repository.
Require the provided PSR-4 autoloader to use ActivityStreams objects
require_once '[path where you cloned or downloaded this library]/autoload.php';
Usage
Let start with the first https://www.w3.org/TR/activitystreams-core/ example.
Objects to JSON
use Patbator\ActivityStreams\Model\Note;
use Patbator\ActivityStreams\Stream;
$note = new Note;
$note->content('My dog has fleas.');
$note->summary('A note');
$stream = new Stream($item);
echo $stream->render();
Will output :
{
"@context": "https://www.w3.org/ns/activitystreams",
"content": "My dog has fleas.",
"summary": "A note",
"type": "Note"
}
JSON to objects
use Patbator\ActivityStreams\Stream;
$note = Stream::fromJson('{
"@context": "https://www.w3.org/ns/activitystreams",
"summary": "A note",
"type": "Note",
"content": "My dog has fleas."
}')->getRoot();
echo $note->content();
Will output :
My dog has fleas.
See tests for more usage samples.
Extending
You could need to provide your own class for a type, for example to implement https://www.w3.org/wiki/SocialCG/ActivityPub/Authentication_Authorization.
Imagine you want an Service having a `publicKey` property.
use \Patbator\ActivityStreams\Model\Service;
class My_ActivityPub_Service extends Service
{
public function __construct()
{
parent::__construct();
$this->_actor_attribs[] = 'publicKey';
}
public function type()
{
return 'Service';
}
}
You can declare it to type factory:
use Patbator\ActivityStreams\Model\Base;
use Patbator\ActivityStreams\Model\Factory;
Base::setFactory((new Factory)
->mapTypeToClass('Service', 'My_ActivityPub_Service'));
After that, factory will create a new `My_ActiviyPub_Servicefor any json object with"type": "Service"instead of a\Patbator\ActivityStreams\Model\Service`.
Testing
$ composer test
License
The MIT License (MIT). Please see LICENSE.md for more information.
patbator/activitystreams 适用场景与选型建议
patbator/activitystreams 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「activitystreams」 「Federation」 「as2」 「activity-streams」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 patbator/activitystreams 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 patbator/activitystreams 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 patbator/activitystreams 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PHP implementation of ActivityPub protocol based upon the ActivityStreams 2.0 data format.
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
Utility for creating GraphQL microservices, which can be combined into a single endpoint through tools like Apollo Gateway
Temporary package which contains a fork of https://github.com/landrok/activitypub with changes for the Drupal AP module.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-17