PHPackages                             datarangers/datarangers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. datarangers/datarangers

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

datarangers/datarangers
=======================

DataRangers服务端埋点PHP SDK

1.0.13(1y ago)33.8k↓50%2[1 PRs](https://github.com/volcengine/datarangers-sdk-php/pulls)Apache-2.0PHP

Since Dec 8Pushed 1y ago3 watchersCompare

[ Source](https://github.com/volcengine/datarangers-sdk-php)[ Packagist](https://packagist.org/packages/datarangers/datarangers)[ RSS](/packages/datarangers-datarangers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (18)Used By (0)

DataRangers
===========

[](#datarangers)

项目背景
----

[](#项目背景)

datarangers-sdk-php是 [DataRangers](https://datarangers.com.cn/) 的用户行为采集服务端SDK。

服务端埋点支持在客户的服务端进行埋点采集和上报，作为客户端埋点的补充或替代，其支持的典型场景包括：

1. 客户端埋点+服务端埋点组合：该场景下，服务端埋点一般用来弥补客户端埋点覆盖不到的部分数据，是目前最常见的使用场景。
2. 纯服务端埋点：所有的埋点收集和上报都由服务端完成，需要的客户端数据则由服务端收集和提取后上报到DataRangers。

使用方法
----

[](#使用方法)

1. 新建一个Laravel项目
2. 在composer.json中添加如下字段

    ```
    {
    "require": {
            "datarangers/datarangers": "^1.0"
        }
    }
    ```
3. 执行命令

    ```
    composer require datarangers/datarangers
    ```
4. 首先加载配置项

    ```
    # 私有化部署场景 logagent模式
    CollectorConfig::init_datarangers_collector([
            "domain" => "http://domain",
            "save" => true,
            "headers" => [
                "Content-Type" => "application/json"
            ],
            "http_timeout"=> 10000
        ]);

    # 私有化部署场景 http 模式
    CollectorConfig::init_datarangers_collector([
    "domain" => "https://xxxx",
    "save" => false,
    "headers" => [
        "Content-Type" => "application/json"
    ],
    "http_timeout"=> 10000
    ]);

    # saas 云上环境
    CollectorConfig::init_datarangers_collector([
        "domain" => "https://xxxx",
        "save" => false,
        "headers" => [
            "Content-Type" => "application/json"
        ],
        "app_keys" => [
            1001 => getenv("APP_KEY")
        ],
        "openapi" => [
            "domain" => "https://xxxx",
            "ak" => getenv("OPENAPI_AK"),
            "sk" => getenv("OPENAPI_SK")
        ],
        "http_timeout"=> 10000
    ]);
    ```

    domain 配置说明：

    1. 私有化，请联系部署运维人员获取
    2. saas，根据接入的环境配置不同的地址：
        1. saas版本国内站：
        2. SaaS版国际站:
    3. SAAS 上如果上报 item 和用户属性，需要设置openapi：
        1. domain:
            1. SaaS版国内站:
            2. SaaS版国际站:
        2. ak/sk 请联系客户经理获取
5. 执行代码

    ```
    $rc = new AppEventCollector();
    $rc->sendEvent("uuid16980", 1001, null, [ProfileMethod::SET, "php_event"],
        [["php_name" => "php", "php_version" => "5.6"], ["php_name" => "php", "php_version" => "5.6"]]);

    $rc->profileSet("uuid16980", 1001,["php_name" => "php", "php_version" => "5.6"]);
    $rc->profileSetOnce("uuid16980", 1001,["php_name" => "php", "php_version" => "5.6"]);
    $rc->profileIncrement("uuid16980", 1001,["count" => 6]);
    $rc->profileAppend("uuid16980", 1001,["php_arr" => ["index1","index2"]]);

    # set item properties
    $rc->itemIdSet(getenv("APP_ID"), "book", "book3", ["author" => "吴承恩", "name" => "西游记", "price" => 59.90, "category" => 1]);
    $rc->itemIdSet(getenv("APP_ID"), "book", "book4", ["author" => "Guanzhong Luo", "name" => "SanGuoYanYi", "price" => 69.90, "category" => 1]);

    # 在事件中上报item
    $rc->sendEvent("test-uuidsdk1", getenv("APP_ID"), null, "php_single_event_with_item",
        ["php_name" => "php", "php_version" => "5.6"],
        [["item_name" => "book", "item_id" => "book3"], ["item_name" => "book", "item_id" => "book4"]]
    );
    ```

License
-------

[](#license)

Copyright 2020 Beijing Volcano Engine Technology Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance41

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 52.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~122 days

Recently: every ~208 days

Total

13

Last Release

515d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c30b50061673df42312f6876d2542e1c3c72439ebb205e0f0fde639a4094aca?d=identicon)[datarangers-sdk](/maintainers/datarangers-sdk)

---

Top Contributors

[![hTangle](https://avatars.githubusercontent.com/u/39337724?v=4)](https://github.com/hTangle "hTangle (30 commits)")[![zhangpengspin](https://avatars.githubusercontent.com/u/85116083?v=4)](https://github.com/zhangpengspin "zhangpengspin (26 commits)")[![easerene](https://avatars.githubusercontent.com/u/6889798?v=4)](https://github.com/easerene "easerene (1 commits)")

### Embed Badge

![Health badge](/badges/datarangers-datarangers/health.svg)

```
[![Health](https://phpackages.com/badges/datarangers-datarangers/health.svg)](https://phpackages.com/packages/datarangers-datarangers)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
