PHPackages                             siam/spm-sdk - 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. siam/spm-sdk

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

siam/spm-sdk
============

siam project manage report sdk;fast reoprt api or exception infn,review them,and solve them.let the world has not bug!!!

0.06(6y ago)3131[1 PRs](https://github.com/xuanyanwow/spm-sdk/pulls)Apache-2.0PHP

Since Nov 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/xuanyanwow/spm-sdk)[ Packagist](https://packagist.org/packages/siam/spm-sdk)[ RSS](/packages/siam-spm-sdk/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

SPM-SDK
=======

[](#spm-sdk)

上报SiamProjectManage项目平台使用

封装上报流程，项目内使用。

安装
==

[](#安装)

```
composer require siam/spm-sdk

```

开始使用
====

[](#开始使用)

配置sdk

在全局的地方注册配置信息，如入口文件、配置文件

```
use spm\Config;
use spm\Reporter;

$config = new Config();
$config->setUrl("http://www.spm.com/public/index.php");
$config->setProjectId(1); // 项目id

Reporter::instance($config);
```

api统计上报
-------

[](#api统计上报)

接着可以继续记录开始时间（这里提供辅助类，可以自己实现）

```
use spm\utility\Timer;

Timer::start();
```

在业务逻辑结束后，上报api（建议封装对客户端的响应方法，在封装里增加上报逻辑，全局生效）

伪代码

```
public function response($code, $data, $msg, $apiReport = [])
```

```
use spm\exception\Exception;
use spm\exception\TimerException;
use spm\utility\Timer;
use spm\bean\ApiDataBean;
use spm\Reporter;

$param = [
    'key1' => 'value1',
    'key2' => 'value2',
];

try{
    $apiLog = new ApiDataBean();
    $apiLog->setCategory("Wechat"); // 接口名 - 分类
    $apiLog->setMethod("jspay");  // 接口名 - 方法
    $apiLog->setUserFrom("Siam"); // 调用api的客户来源标识
    $apiLog->setUserIdentify(time().rand(1000,9999)); // 标识，比如订单号 用于后台追溯查看
    $apiLog->setApiResponse(json_encode($param)); // 响应给客户端的内容 比如json字符串 xml字符串等
    $apiLog->setConsumeTime(Timer::end());
    $apiLog->setApiParam($param);
    $apiLog->setIsSuccess(ApiDataBean::SUCCESS); // 可选ApiDataBean::FAIL
} catch (Exception $e) {
    return $e->getMessage();
} catch (TimerException $e) {
    return $e->getMessage();
}

Reporter::instance()->report($apiLog);
```

异常上报
----

[](#异常上报)

在程序通用异常处理的地方，比如php中的「注册异常处理函数」，获得程序数据，上报统计平台

```
use spm\bean\ExceptionDataBean;
use spm\Reporter;

$bean = new ExceptionDataBean();
$bean->setAbClass('\Siam\test\Class');
$bean->setAbData([
    'get' => [
        'field1' => 'value1'
    ]
]);
$bean->setAbDate(date('Y-m-d'));
$bean->setAbFile("错误的文件地址");
$bean->setAbFileresources([
    [//[{"is_hight":0, "text": "代码", "line" :100}, {"is_hight":1, "text": "代码2", "line" :101}]
        'is_hight' => 0, // 是否高亮
        'text'     => "内容",
        'line' => "行号"
    ]
]);
$bean->setAbLine(320);
$bean->setAbStack([
    ['第一行stack'],
    ['第二行stack'],
]);
$bean->setAbMessage("错误消息");
Reporter::instance()->exception_report($bean);
```

日志上报
----

[](#日志上报)

```
use spm\bean\LogDataBean;
use spm\Reporter;

$bean = new LogDataBean();
$bean->setLogCategory("Wechat/Test/SDK");
$bean->setLogData('{"key": "value"}');
$bean->setLogFrom("SDK");
$bean->setLogPoint("test guzzle");
$bean->setLogSn("123456");
Reporter::instance()->log($bean);
```

可以懒上报，多个结果一次性上报 减少http tcp握手等消耗

```
$config = new \spm\Config();
$config->setUrl("http://www.siam.com/public/index.php");
$config->setProjectId(1);
Reporter::instance($config);

$config->setLazyLog(true);

$bean = new LogDataBean();
$bean->setLogCategory("Wechat/Test_lazy/SDK");
$bean->setLogData('{"key": "value"}');
$bean->setLogFrom("SDK");
$bean->setLogPoint("test guzzle");
$bean->setLogSn("20191128");
Reporter::instance()->log($bean); // 此时不会真正发送

$bean = new LogDataBean();
$bean->setLogCategory("Wechat/Test_lazy/SDK");
$bean->setLogData('22222');
$bean->setLogFrom("SDK");
$bean->setLogPoint("test guzzle");
$bean->setLogSn("20191128");
Reporter::instance()->log($bean);

Reporter::instance()->lazy_log_send(); // 懒上报
```

事务管理
----

[](#事务管理)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

6

Last Release

2358d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/217347?v=4)[Saeed Siam](/maintainers/siam)[@siam](https://github.com/siam)

---

Top Contributors

[![xuanyanwow](https://avatars.githubusercontent.com/u/28777109?v=4)](https://github.com/xuanyanwow "xuanyanwow (11 commits)")

### Embed Badge

![Health badge](/badges/siam-spm-sdk/health.svg)

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

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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