定制 lokielse/aliyun-open-api-sls 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lokielse/aliyun-open-api-sls

最新稳定版本:v1.0.0

Composer 安装命令:

composer require lokielse/aliyun-open-api-sls

包简介

The SLS SDK for Aliyun OpenAPI

README 文档

README

Latest Version on Packagist Software License Total Downloads

The SLS SDK for Aliyun OpenAPI

Install

Via Composer

$ composer require lokielse/aliyun-open-api-sls

Usage

/**  * Config  */ $config = [ 'AccessKeyId' => 'your_access_key_id', 'AccessKeySecret' => 'your_access_key_secret', 'endpoint' => 'cn-hangzhou.sls.aliyuncs.com', 'project' => 'your_sls_project_name', 'logStore' => 'your_sls_log_store_name', 'topic' => '', 'source' => '', ]; /**  * 写日志 (Write Logs)  */ $logs = array( new LogItem([ 'user' => 'jello', 'action' => 'trash_photo', 'object_id' => 123456 ]), new LogItem([ 'user' => 'frank', 'action' => 'delete_user', 'object_id' => 100236 ]), ); $putLogsRequest = new PutLogsRequest($config['project'], $config['logStore'], $config['topic'], $config['source'], $logs); $client = new Client($config['endpoint'], $config['AccessKeyId'], $config['AccessKeySecret']); $putLogsResponse = $client->putLogs($putLogsRequest); /**  * 读日志 (Read Logs)  * 在控制台查看日志有3-5分钟延迟, 但是使用该SDK查看无延迟  */ $listShardRequest = new ListShardsRequest($config['project'], $config['logStore']); $listShardResponse = $client->listShards($listShardRequest); foreach ($listShardResponse->getShardIds() as $shardId) { /**  * 对每一个ShardId,先获取Cursor  */ $getCursorRequest = new GetCursorRequest($config['project'], $config['logStore'], $shardId, null, time() - 60); $response = $client->getCursor($getCursorRequest); $cursor = $response->getCursor(); $count = 100; while (true) { /**  * 从cursor开始读数据  */ $batchGetDataRequest = new BatchGetLogsRequest($config['project'], $config['logStore'], $shardId, $count, $cursor); var_dump($batchGetDataRequest); $response = $client->batchGetLogs($batchGetDataRequest); if ($cursor == $response->getNextCursor()) { break; } $logGroupList = $response->getLogGroupList(); /**  * @var \Aliyun\SLS\Log\LogGroup $logGroup  * @var Aliyun\SLS\Log\Log $log  * @var Aliyun\SLS\Log\LogContent $content  */ foreach ($logGroupList as $logGroup) { print ( $logGroup->getCategory() ); foreach ($logGroup->getLogsArray() as $log) { foreach ($log->getContentsArray() as $content) { print( $content->getKey() . ":" . $content->getValue() . "\t" ); } print( "\n" ); } } $cursor = $response->getNextCursor(); } }

官方文档

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email lokielse@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 59.51k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固