PHPackages                             unntech/minio-php-s3 - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. unntech/minio-php-s3

ActiveLibrary[HTTP &amp; Networking](/categories/http)

unntech/minio-php-s3
====================

minio SDK for PHP - use Amazon Web Services sdk

v1.0.1(11mo ago)05MITPHPPHP &gt;=7.2.5

Since Jun 19Pushed 11mo agoCompare

[ Source](https://github.com/unntech/minio-php-s3)[ Packagist](https://packagist.org/packages/unntech/minio-php-s3)[ RSS](/packages/unntech-minio-php-s3/feed)WikiDiscussions master Synced 1mo ago

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

minio-php-s3 1.0
================

[](#minio-php-s3-10)

[![Latest Stable Version](https://camo.githubusercontent.com/eec203ec7436ded204c76e0101033bda6a16a8b4547d0ba04f4a7893ca415b09/68747470733a2f2f706f7365722e707567782e6f72672f756e6e746563682f6d696e696f2d7068702d73332f762f737461626c65)](https://packagist.org/packages/unntech/minio-php-s3)[![Total Downloads](https://camo.githubusercontent.com/f34477d51730c29d909117a3e230fe26aaf42872dfec497661cff55a9154a317/68747470733a2f2f706f7365722e707567782e6f72672f756e6e746563682f6d696e696f2d7068702d73332f646f776e6c6f616473)](https://packagist.org/packages/unntech/minio-php-s3)[![Latest Unstable Version](https://camo.githubusercontent.com/a76ed8fe0b0e1db2b73e73b02b376f9708b91adc8f60e66dfc2bee022130c816/687474703a2f2f706f7365722e707567782e6f72672f756e6e746563682f6d696e696f2d7068702d73332f762f756e737461626c65)](https://packagist.org/packages/unntech/minio-php-s3)[![PHP Version Require](https://camo.githubusercontent.com/b32edd745dffa61c675881a332dc90042907433aa5920191dcb82a5c7fe91570/687474703a2f2f706f7365722e707567782e6f72672f756e6e746563682f6d696e696f2d7068702d73332f726571756972652f706870)](https://packagist.org/packages/unntech/minio-php-s3)

- 依据 Amazon S3 SDK aws/aws-sdk-php:3.293.2
- 只复制关于`S3`和`sts`模块代码，精减没有使用的模块代码，解决项目下载大量没用到的代码，文件提交量大等问题
- 只修改命名空间 `Aws` 为 `MinioS3`， 解决与原命名空间冲突问题

开发文档
----

[](#开发文档)

>
> [https://docs.aws.amazon.com/zh\_cn/sdk-for-php/v3/developer-guide/credentials.html](https://docs.aws.amazon.com/zh_cn/sdk-for-php/v3/developer-guide/credentials.html)

安装
--

[](#安装)

```
composer require unntech/minio-php-s3

```

参与开发
----

[](#参与开发)

- 直接提交PR或者Issue即可
- 期望 Amazon 和 minio 可以直接出 PHP 的 minio SDK，方便PHP用户群体使用

使用示例
----

[](#使用示例)

### 获取STS临时凭证

[](#获取sts临时凭证)

```
use MinioS3\Sts\StsClient;

$stsClient = new StsClient([
    'credentials' => [
        'key'    => 'key',
        'secret' => 'secret'
    ],
    'region' => 'cn-default-1',
    'version' => 'latest',
    'bucket_endpoint' => false,
    'use_path_style_endpoint' => true,
    'endpoint'  => 'http://127.0.0.1:9801'
]);
$assumeRoleResult = $stsClient->assumeRole([
    'RoleArn' => 'arn:ssssxxx:xxx:xxx:xxxx',
    'RoleSessionName' => 'role-session-name'
]);

$res = $stsClient->createCredentials($assumeRoleResult);
$sts = $res->toArray();

var_dump($sts);
```

### 操作 S3 示例

[](#操作-s3-示例)

```
use MinioS3\S3\PostObjectV4;
use MinioS3\S3\S3Client;

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'cn-default-1',
    'endpoint' => 'http://127.0.0.1:9801',
    'bucket_endpoint' => false,
    'use_path_style_endpoint' => true,
    'credentials' => [
        'key'    => 'key',
        'secret' => 'secret',
        //'token'  => $sts['token'],
    ],
]);

// 列出所有对象
$res = $s3->listObjectsV2([
    'Bucket' => 'pub'
]);
//var_dump($res);

// 复制对象
$result = $s3->copyObject([
    'Bucket' => 'pub',
    'CopySource' => '/pub/a.txt',
    'Key' => 'b.txt',
]);
var_dump($result);

//删除对象
$res = $s3->deleteObject([
    'Bucket' => 'pub',
    'Key'    => 'b.txt'
]);

var_dump($res);

// 上传对象
$insert = $s3->putObject([
    'Bucket' => 'pub',
    'Key'    => 'c.txt',
    // 'SourceFile'  => $sourceFileName,    // 使用文件上传
    'Body'   => 'Hello from MinIO!! exm',   // 文件内容
    'ContentType' => 'text/plain'
]);

var_dump($insert);

var_dump($insert['ObjectURL']);

// 下载文件的内容
$retrive = $s3->getObject([
    'Bucket' => 'pub',
    'Key'    => 'a.txt',
    'SaveAs' => './a.txt'
]);
var_dump($retrive);

//获得一个10分钟有效期的pre-signed URL
$command       = $s3->getCommand('GetObject', [
    'Bucket' => 'pub',
    'Key'    => 'a.txt',
]);
$signedRequest = $s3->createPresignedRequest($command, "+600 seconds");
var_dump((string)$signedRequest->getUri());

// 获取一个临时上传地址，交前端上传文件
$options = [
    ['acl' => 'public-read'],
    ['bucket' => 'pub'],
    ['key' => 'p.txt'],
];
$formInputs = ['acl' => 'public-read', 'key' => 'p.txt'];
$postObject = new PostObjectV4(
    $s3,
    'pub',
    $formInputs,
    $options,
    '+2 hours'
);
$data = [
    'endpoint'=>$postObject->getFormAttributes(),
    'form'=>$postObject->getFormInputs(),
];
var_dump($data);
```

### S3 分片上传

[](#s3-分片上传)

```
use MinioS3\Exception\MultipartUploadException;
use MinioS3\S3\MultipartUploader;

// Use multipart upload 分段上传
$source = './a.zip';
$uploader = new MultipartUploader($s3, $source, [
    'bucket' => 'pub',
    'key' => 'a1.zip',
]);

try {
    $result = $uploader->upload();
    echo "Upload complete: {$result['ObjectURL']}\n";
} catch (MultipartUploadException $e) {
    echo $e->getMessage() . "\n";
}
```

版权信息
----

[](#版权信息)

Apache License 2.0

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance52

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

333d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/41ed0737519313bb52a1c118a720dd65f4c238a2a805825eeef7bf2b41e05bfa?d=identicon)[unntech](/maintainers/unntech)

---

Top Contributors

[![unntech](https://avatars.githubusercontent.com/u/98684048?v=4)](https://github.com/unntech "unntech (1 commits)")

### Embed Badge

![Health badge](/badges/unntech-minio-php-s3/health.svg)

```
[![Health](https://phpackages.com/badges/unntech-minio-php-s3/health.svg)](https://phpackages.com/packages/unntech-minio-php-s3)
```

###  Alternatives

[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

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