PHPackages                             seffeng/aliyun-sls - 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. [API Development](/categories/api)
4. /
5. seffeng/aliyun-sls

ActiveLibrary[API Development](/categories/api)

seffeng/aliyun-sls
==================

The SLS SDK for Aliyun OpenAPI

v0.1.0(5y ago)04.5k2[1 PRs](https://github.com/seffeng/php-aliyun-sls/pulls)1MITPHPPHP &gt;=5.3.0

Since Dec 9Pushed 3y agoCompare

[ Source](https://github.com/seffeng/php-aliyun-sls)[ Packagist](https://packagist.org/packages/seffeng/aliyun-sls)[ Docs](https://github.com/seffeng/php-aliyun-sls)[ RSS](/packages/seffeng-aliyun-sls/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

The SLS SDK for Aliyun OpenAPI
==============================

[](#the-sls-sdk-for-aliyun-openapi)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b4a22244bf4dc7f7f4f2a961dfb635ce79aca1a427110d2190fd4ab3bcc8aea4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6b69656c73652f616c6979756e2d6f70656e2d6170692d736c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lokielse/aliyun-open-api-sls)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/b24a56e0dd7e1112f26f3aaf6567feaa651a17055ae014f19da3777e4c6e46bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6b69656c73652f616c6979756e2d6f70656e2d6170692d736c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lokielse/aliyun-open-api-sls)

The SLS SDK for Aliyun OpenAPI

Install
-------

[](#install)

Via Composer

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

Usage
-----

[](#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();
	}
}
```

[官方文档](https://help.aliyun.com/document_detail/29074.html)

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Lokielse](https://github.com/lokielse)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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

Unknown

Total

1

Last Release

1979d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/30b3d8cc986a1ad37a55169b11812fea1cae31430dd8dbe1b3436dc58cc885bd?d=identicon)[seffeng](/maintainers/seffeng)

---

Top Contributors

[![lokielse](https://avatars.githubusercontent.com/u/1573211?v=4)](https://github.com/lokielse "lokielse (3 commits)")[![seffeng](https://avatars.githubusercontent.com/u/3509779?v=4)](https://github.com/seffeng "seffeng (1 commits)")

### Embed Badge

![Health badge](/badges/seffeng-aliyun-sls/health.svg)

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

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M271](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)

PHPackages © 2026

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