PHPackages                             fromthink/upyun-php-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. fromthink/upyun-php-sdk

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

fromthink/upyun-php-sdk
=======================

UPYUN sdk for php

4.0.1(3y ago)0232MITPHPPHP &gt;=5.5.0

Since May 14Pushed 3y agoCompare

[ Source](https://github.com/fromthink/upyun-php-sdk)[ Packagist](https://packagist.org/packages/fromthink/upyun-php-sdk)[ Docs](https://github.com/upyun/php-sdk/)[ RSS](/packages/fromthink-upyun-php-sdk/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (5)Dependencies (4)Versions (23)Used By (2)

又拍云 SDK for PHPer
=================

[](#又拍云-sdk-for-phper)

[![Build Status](https://camo.githubusercontent.com/d7538a5d175c5658eca6e6846a846f53c99372d573c6f74fae92bfd44669c13e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f757079756e2f7068702d73646b2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/upyun/php-sdk/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/53ccf9189012178bfd33f9ba093a9ff8a46b239ed0494f6c73724398f43762dc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f757079756e2f7068702d73646b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/upyun/php-sdk/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/1babd1b3c3bdad8585707ed77b0f4d7cbdd7728a807989492a2ee92dbe22a96e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f757079756e2f7068702d73646b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/upyun/php-sdk/?branch=master)

又拍云 PHP SDK，封装了[又拍云功能丰富的开放 API](http://docs.upyun.com/api/) ，帮助开发者快速对接文件云端存储、图片音视频云处理、智能鉴黄等功能

- [功能列表](#list)
- [使用说明](#use-instructions)
    - [安装](#install)
    - [文档](#doc)
    - [示例](#usage)
- [贡献代码](#contribute)
- [社区](#community)
- [许可证](#license)

功能列表
----

[](#功能列表)

SDK 包含如下功能

- 基于 [rest api](http://docs.upyun.com/api/rest_api/)
    - 文件上传下载、目录创建删除等云存储基本操作
    - [断点续传](http://docs.upyun.com/api/rest_api/#_3)
- 基于 [form api](http://docs.upyun.com/api/form_api/)
    - 文件客户端上传 见`examples/client-upload`
    - 上传预处理操作
        - [同步音频处理](http://docs.upyun.com/cloud/sync_audio/)
        - [文档转换](http://docs.upyun.com/cloud/uconvert/)
        - [异步图片音视频处理](http://docs.upyun.com/api/form_api/#_7)
        - [异步图片智能鉴黄](http://docs.upyun.com/ai/audit/)
- [异步云处理](http://docs.upyun.com/cloud/)
    - [视频音频](http://docs.upyun.com/cloud/av/)异步转码、切片、截图、水印、剪辑、拼接等功能
    - [文件异步解压缩](http://docs.upyun.com/cloud/unzip/)
    - [文件异步拉取](http://docs.upyun.com/cloud/spider/)
    - [异步图片拼接](http://docs.upyun.com/cloud/async_image/)
- [同步视频处理](http://docs.upyun.com/cloud/sync_video/)：m3u8 文件同步拼接剪辑、其他视频文件同步截图功能
- [缓存刷新](http://docs.upyun.com/api/purge/)

*功能列表中的异步操作，均可以设置异步回调通知地址，接收异步处理结果**如果需要测试回调功能，可以通过[又拍云回调服务](https://hooks.upyun.com/)创建一个临时回调地址*

使用说明
----

[](#使用说明)

### 安装

[](#安装)

#### PHP &gt;= 5.5

[](#php--55)

1.使用 `composer` 安装

推荐使用该方法安装，成为优雅的 PHPer 🔥

建议使用速度很快的国内[全量镜像](https://pkg.phpcomposer.com/#how-to-use-packagist-mirror)([又拍云赞助](https://pkg.phpcomposer.com/#donation))

```
composer require upyun/sdk

```

2.如果不适应 `composer` 管理，可以直接下载[压缩包](https://github.com/upyun/php-sdk/releases)(注意需要下载 `php-sdk-版本号.zip` 格式的 zip 压缩包，不是 Source code 源码压缩包)，解压后，项目中添加如下代码：

```
require_once '/path/to/php-sdk/vendor/autoload.php';

```

### 文档

[](#文档)

详细文档见 [doc.md](doc.md)

### 示例

[](#示例)

先初始化又拍云服务配置：

```
require_once('vendor/autoload.php'); // 只针对使用 composer 安装
// require_once '/path/to/php-sdk/vendor/autoload.php'; // 针对压缩包安装

use Upyun\Upyun;
use Upyun\Config;
$serviceConfig = new Config('yourServiceName', 'yourOperatorName', 'yourOperatorPwd');
$client = new Upyun($serviceConfig);
```

#### 字符串写入又拍云服务器

[](#字符串写入又拍云服务器)

```
$client->write('/save/path', 'file content');

```

#### 文件流写入又拍云服务器

[](#文件流写入又拍云服务器)

```
$file = fopen('/local/path/file', 'r');
$client->write('/save/path', $file);

```

#### 使用并行式断点续传上传文件

[](#使用并行式断点续传上传文件)

```
$serviceConfig->setUploadType('BLOCK_PARALLEL');
$client = new Upyun($serviceConfig);
$file = fopen('/local/path/file', 'r');
$client->write('/save/path', $file);

```

#### 上传图片并转换格式为 `png`，详见[上传作图](http://docs.upyun.com/cloud/image/#_2)

[](#上传图片并转换格式为-png详见上传作图)

```
$file = fopen('/local/path/image.jpg', 'r');
$client->write('/save/image.png', $file, array('x-gmkerl-thumb' => '/format/png'));

```

#### 下载文件并保存到本地

[](#下载文件并保存到本地)

```
$saveLocal = fopen('/local/path/image.jpg', 'w');
// 第二个参数不传时，read 方法将直接返回文件内容
$client->read('/remote/server/image.png', $saveLocal);

```

贡献代码
----

[](#贡献代码)

1. Fork
2. 为新特性创建一个新的分支
3. 发送一个 pull request 到 master 分支

社区
--

[](#社区)

- [问答社区](http://segmentfault.com/upyun)
- [微博](http://weibo.com/upaiyun)

许可证
---

[](#许可证)

UPYUN PHP-SDK 基于 MIT 开源协议

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 66.3% 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 ~119 days

Recently: every ~3 days

Total

20

Last Release

1371d ago

Major Versions

2.2.1 → 3.0.0-RC12016-12-21

3.52 → 4.02022-08-06

PHP version history (2 changes)2.2.0PHP &gt;=5.3.0

3.0.0-RC1PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2468c6f2b42df0691195d7594d4777e8575653239a51244fb5a0a31ac2908a53?d=identicon)[fromthink](/maintainers/fromthink)

---

Top Contributors

[![sabakugaara](https://avatars.githubusercontent.com/u/3990917?v=4)](https://github.com/sabakugaara "sabakugaara (112 commits)")[![lfeng](https://avatars.githubusercontent.com/u/103457?v=4)](https://github.com/lfeng "lfeng (39 commits)")[![fromthink](https://avatars.githubusercontent.com/u/27845963?v=4)](https://github.com/fromthink "fromthink (7 commits)")[![our80](https://avatars.githubusercontent.com/u/2969393?v=4)](https://github.com/our80 "our80 (3 commits)")[![phy25](https://avatars.githubusercontent.com/u/331403?v=4)](https://github.com/phy25 "phy25 (1 commits)")[![timebug](https://avatars.githubusercontent.com/u/416154?v=4)](https://github.com/timebug "timebug (1 commits)")[![totoleo](https://avatars.githubusercontent.com/u/4956722?v=4)](https://github.com/totoleo "totoleo (1 commits)")[![ckaqq](https://avatars.githubusercontent.com/u/11495438?v=4)](https://github.com/ckaqq "ckaqq (1 commits)")[![yejingx](https://avatars.githubusercontent.com/u/2890050?v=4)](https://github.com/yejingx "yejingx (1 commits)")[![forthe2008](https://avatars.githubusercontent.com/u/24647448?v=4)](https://github.com/forthe2008 "forthe2008 (1 commits)")[![khs1994](https://avatars.githubusercontent.com/u/16733187?v=4)](https://github.com/khs1994 "khs1994 (1 commits)")[![lvye](https://avatars.githubusercontent.com/u/4340161?v=4)](https://github.com/lvye "lvye (1 commits)")

---

Tags

upyun

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fromthink-upyun-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/fromthink-upyun-php-sdk/health.svg)](https://phpackages.com/packages/fromthink-upyun-php-sdk)
```

###  Alternatives

[upyun/sdk

UPYUN sdk for php

174100.6k22](/packages/upyun-sdk)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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