PHPackages                             qcloud/cos-sdk-v4 - 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. qcloud/cos-sdk-v4

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

qcloud/cos-sdk-v4
=================

PHP SDK for QCloud COS

v4.3.11(8y ago)4121.9k—0%19[1 PRs](https://github.com/tencentyun/cos-php-sdk-v4/pulls)2MITPHPPHP &gt;=5.3.0

Since Jun 26Pushed 7y ago48 watchersCompare

[ Source](https://github.com/tencentyun/cos-php-sdk-v4)[ Packagist](https://packagist.org/packages/qcloud/cos-sdk-v4)[ RSS](/packages/qcloud-cos-sdk-v4/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (12)Used By (2)

cos-php-sdk：php sdk for [腾讯云对象存储服务](https://www.qcloud.com/product/cos.html)
============================================================================

[](#cos-php-sdkphp-sdk-for-腾讯云对象存储服务)

已弃用 - 请升级到 cos-php-sdk-v5
-------------------------

[](#已弃用---请升级到-cos-php-sdk-v5)

SDK 依赖的 JSON API 已弃用，请直接使用基于 XML API 的 [cos-php-sdk-v5](https://github.com/tencentyun/cos-php-sdk-v5)，或者参照 [指引](https://cloud.tencent.com/document/product/436/31695) 升级到新版SDK。

### 安装（直接下载源码集成）

[](#安装直接下载源码集成)

若出现下载失败的问题，请将代码升级到最新的版本(&gt;=v4.3.7)。 直接从[github](https://github.com/tencentyun/cos-php-sdk-v4)下载源码，然后在您的程序中加载cos-php-sdk-v4/include.php就可以了。

### 修改配置

[](#修改配置)

配置使用数组形式

COS所在的区域(region)，对应关系如下：

地区region华南gz华中(华东)sh华北tj```
$config = array(
    'app_id' => '',
    'secret_id' => '',
    'secret_key' => '',
    'region' => 'gz',
    'timeout' => 60
);
```

### 示例程序

[](#示例程序)

请参考sample.php

```
// 包含cos-php-sdk-v4/include.php文件
require('cos-php-sdk-v4/include.php');
use QCloud\Cos\Api;

$config = array(
    'app_id' => '',
    'secret_id' => '',
    'secret_key' => '',
    'region' => 'gz',
    'timeout' => 60
);
$cosApi = new Api($config);

// 创建文件夹
$ret = $cosApi->createFolder($bucket, $folder);
var_dump($ret);

// 上传文件
$ret = $cosApi->upload($bucket, $src, $dst);
var_dump($ret);

// 下载文件
$ret = $cosApi->download($bucket, $src, $dst);
var_dump($ret);

// 目录列表
$ret = $cosApi->listFolder($bucket, $folder);
var_dump($ret);

// 更新目录信息
$bizAttr = "";
$ret = $cosApi->updateFolder($bucket, $folder, $bizAttr);
var_dump($ret);

// 更新文件信息
$bizAttr = '';
$authority = 'eWPrivateRPublic';
$customerHeaders = array(
    'Cache-Control' => 'no',
    'Content-Type' => 'application/pdf',
    'Content-Language' => 'ch',
);
$ret = $cosApi->update($bucket, $dst, $bizAttr, $authority, $customerHeaders);
var_dump($ret);

// 查询目录信息
$ret = $cosApi->statFolder($bucket, $folder);
var_dump($ret);

// 查询文件信息
$ret = $cosApi->stat($bucket, $dst);
var_dump($ret);

// 删除文件
$ret = $cosApi->delFile($bucket, $dst);
var_dump($ret);

// 删除目录
$ret = $cosApi->delFolder($bucket, $folder);
var_dump($ret);

// 复制文件
$ret = $cosApi->copyFile($bucket, '/111.txt', '/111_2.txt');
var_dump($ret);

// 移动文件
$ret = $cosApi->moveFile($bucket, '/111.txt', '/111_3.txt');
var_dump($ret);
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community29

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 50.7% 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 ~30 days

Recently: every ~51 days

Total

10

Last Release

2966d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e6735c4ecc810aa61a07b3507e71c2756fb9e72ba8ba83347c86af34f1e9c67?d=identicon)[lewzylu](/maintainers/lewzylu)

---

Top Contributors

[![yaozongyou](https://avatars.githubusercontent.com/u/590761?v=4)](https://github.com/yaozongyou "yaozongyou (36 commits)")[![lewzylu](https://avatars.githubusercontent.com/u/25299171?v=4)](https://github.com/lewzylu "lewzylu (20 commits)")[![ACTom](https://avatars.githubusercontent.com/u/6156919?v=4)](https://github.com/ACTom "ACTom (5 commits)")[![konakonall](https://avatars.githubusercontent.com/u/900060?v=4)](https://github.com/konakonall "konakonall (5 commits)")[![wangnan8791](https://avatars.githubusercontent.com/u/2181096?v=4)](https://github.com/wangnan8791 "wangnan8791 (2 commits)")[![shijiaxiong](https://avatars.githubusercontent.com/u/13504969?v=4)](https://github.com/shijiaxiong "shijiaxiong (1 commits)")[![tinpont](https://avatars.githubusercontent.com/u/3940642?v=4)](https://github.com/tinpont "tinpont (1 commits)")[![luoxiaojun1992](https://avatars.githubusercontent.com/u/6905700?v=4)](https://github.com/luoxiaojun1992 "luoxiaojun1992 (1 commits)")

---

Tags

phpqcloudcos

### Embed Badge

![Health badge](/badges/qcloud-cos-sdk-v4/health.svg)

```
[![Health](https://phpackages.com/badges/qcloud-cos-sdk-v4/health.svg)](https://phpackages.com/packages/qcloud-cos-sdk-v4)
```

###  Alternatives

[qcloud/cos-sdk-v5

PHP SDK for QCloud COS

2051.5M129](/packages/qcloud-cos-sdk-v5)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)[qcloud_sts/qcloud-sts-sdk

PHP SDK for QCloud STS

10173.3k9](/packages/qcloud-sts-qcloud-sts-sdk)

PHPackages © 2026

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