kregel/tamber
Composer 安装命令:
composer require kregel/tamber
包简介
The PHP SDK for the Tamber API.
README 文档
README
This is an UNOFFICIAL SDK.
Get your api Token by creating an account
The first thing to do is head to the official Tamber website to register
Download the project
When this package is finally on packagist, you'll be able to install it using
composer require kregel/tamber
Usage of this package
Event
<?php require 'vendor/autoload.php'; use Kregel\Tamber\Tamber; use Kregel\Tamber\Event; Tamber::setProjectKey('...'); Tamber::setEngineKey('...'); // If you just created your account you won't be able to set or create an engine until you track at least 1 event. try { $response = (new Event)->track([ /** * This will be created if it doesn't exist by default (via Tamber's code not this package) */ 'user' => 'your user id using whatever format you want', /** * This can be anything from likes, dislikes, purchases, clicks, reads, ect. * This will be created if it doesn't exist by default (via Tamber's code not this package) */ 'behavior' => 'like', /** * If I were using Laravel I might do something like `App\User:1` or `App\Models\Transaction:810`. Something to signify the thing performing * that's performing said beahvior and the identifier to track that thing's previous behaviors. */ 'item' => 'spotify:track:1JIgaRnqtzS7DuGM3hVZU9', /** * The Tamber docs mention the context could be related to A/B testing for interface changes. * but it could also be used to track the user's current url, previous things the user clicked on or other actions that the user preformed * like whether or not they played the song or read the book. */ 'context' => [ 'home-page', ], /** * This is just to indicate whether or not this specific behavior was related to a recommened/suggested action. * i.e. Did they play the song because it was in your recommended list? */ 'hit' => false, ]); print_r($response->getContents()); } catch (\Kregel\Tamber\Exceptions\TamberException $e) { echo $e->getMessage() . "\n"; print_r($e->getContext()); }
Behaviors
<?php use Kregel\Tamber\Tamber; use Kregel\Tamber\Behavior; Tamber::setProjectKey($projectToken); try { $behavior = (new Behavior)->create([ 'name' => 'purchase', 'desirability' => 0.6 ]); } catch (\Kregel\Tamber\Exceptions\TamberException $e) { echo $e->getMessage() . "\n"; print_r($e->getContext()); }
Items
Creating
<?php use Kregel\Tamber\Tamber; use Kregel\Tamber\Item; Tamber::setProjectKey($projectToken); try { $item = (new Item)->create([ 'id' => 'App\Song:1', // This just needs to be some kind of unique identifier. 'properties' => [ 'artist' => 'Logic', 'title' => 'Under Pressure', 'length' => '9:20', 'explicit' => true ], 'tags' => [ 'rap', 'hip-hop' ], 'created' => App\Song::find(1)->created_at // This is just to represent when the song was created in your system. ]); } catch (\Kregel\Tamber\Exceptions\TamberException $e) { echo $e->getMessage() . "\n"; print_r($e->getContext()); }
Getting an item
<?php use Kregel\Tamber\Tamber; use Kregel\Tamber\Item; Tamber::setProjectKey($projectToken); $item = (new Item)->retrieve([ 'id' => 'spotify:track:5LME7YULt0enp6UAB8VoDn' ]);
Side notes
It should be noted that each item in the Tamber API uses the TransformRequest trait. That means we hijack the
calls to the SDK and transform them into something a bit more usable.
Using the behavior creation example above. You can access any of the response data by simply trying to access it from the behavior variable.
$behavior->result->name // purchase $behavior->status // 200 $behavior->success // true // ect...
kregel/tamber 适用场景与选型建议
kregel/tamber 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「engine」 「recommendation」 「tamber」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kregel/tamber 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kregel/tamber 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kregel/tamber 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Allow KoolReport to use twig template engine to render view
Simple template engine
Engine
Logging for PHP 5.3
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-21