PHPackages                             tencentyun/cos-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. [File &amp; Storage](/categories/file-storage)
4. /
5. tencentyun/cos-php-sdk

ActiveLibrary[File &amp; Storage](/categories/file-storage)

tencentyun/cos-php-sdk
======================

php sdk for www.qcloud.com cos service

3.3(9y ago)201.4k15[1 issues](https://github.com/tencentyun/cos-php-sdk/issues)1MITPHPPHP &gt;=5.3.0

Since Oct 27Pushed 7y ago12 watchersCompare

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

READMEChangelog (6)DependenciesVersions (8)Used By (1)

tencentyun-cos-php
------------------

[](#tencentyun-cos-php)

SDK for [腾讯云对象存储服务](http://wiki.qcloud.com/wiki/COS%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D)

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

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

SDK 依赖的 API 已弃用，请直接使用基于 XML API 的 [cos-php-sdk-v5](https://github.com/tencentyun/cos-php-sdk-v5)。

源码集成
----

[](#源码集成)

从github下载源码装入到您的程序中，并加载include.php

修改配置
----

[](#修改配置)

修改Qcloud\_cos/Conf.php内的APPID、SECRET\_ID、SECRET\_KEY等信息为您的配置

程序示例（sample.php）
----------------

[](#程序示例samplephp)

```
require('./include.php');
use Qcloud_cos\Auth;
use Qcloud_cos\Cosapi;
use Qcloud_cos\CosDb;

Cosapi::setTimeout(180);

//创建文件夹
$bucketName = 'test';
$srcPath = './test.log';
$dstPath = '/sdk/test.log';
$dstFolder = '/sdk/';
$createFolderRet = Cosapi::createFolder($bucketName, $dstFolder);
var_dump($createFolderRet);

//上传文件
$bizAttr = "";
$insertOnly = 0;
$sliceSize = 3 * 1024 * 1024;
$uploadRet = Cosapi::upload($bucketName, $srcPath, $dstPath,$bizAttr,$sliceSize, $insertOnly);
var_dump($uploadRet);

//目录列表
$listnum = 20;
$pattern = "eListBoth";
$order = 0;
$listRet = Cosapi::listFolder($bucketName, $dstFolder,$listnum,$pattern, $order);
var_dump($listRet);

//更新目录信息
$bizAttr = "";
$updateRet = Cosapi::updateFolder($bucketName, $dstFolder, $bizAttr);
var_dump($updateRet);

//更新文件信息
$bizAttr = "";
$authority = "eWPrivateRPublic";
$customer_headers_array = array(
    'Cache-Control' => "no",
    'Content-Type' => "application/pdf",
    'Content-Language' => "ch",
);
$updateRet = Cosapi::update($bucketName, $dstPath, $bizAttr,$authority, $customer_headers_array);
var_dump($updateRet);

//查询目录信息
$statRet = Cosapi::statFolder($bucketName, $dstFolder);
var_dump($statRet);

//查询文件信息
$statRet = Cosapi::stat($bucketName, $dstPath);
var_dump($statRet);

//删除文件
$delRet = Cosapi::delFile($bucketName, $dstPath);
var_dump($delRet);

//删除目录
$delRet = Cosapi::delFolder($bucketName, $dstFolder);
var_dump($delRet);
```

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~39 days

Recently: every ~58 days

Total

7

Last Release

3613d ago

Major Versions

2.0.4 → 3.32016-06-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/c028cb543180610157052bd526e8866079ec516c69a5d18c08ed19849074d9cb?d=identicon)[moria](/maintainers/moria)

---

Top Contributors

[![wangnan8791](https://avatars.githubusercontent.com/u/2181096?v=4)](https://github.com/wangnan8791 "wangnan8791 (13 commits)")[![moria](https://avatars.githubusercontent.com/u/1073005?v=4)](https://github.com/moria "moria (7 commits)")[![woshixujiang](https://avatars.githubusercontent.com/u/19649269?v=4)](https://github.com/woshixujiang "woshixujiang (3 commits)")[![csky2013](https://avatars.githubusercontent.com/u/4463204?v=4)](https://github.com/csky2013 "csky2013 (2 commits)")[![cliffordsun](https://avatars.githubusercontent.com/u/6119425?v=4)](https://github.com/cliffordsun "cliffordsun (2 commits)")[![konakonall](https://avatars.githubusercontent.com/u/900060?v=4)](https://github.com/konakonall "konakonall (1 commits)")[![degangliu](https://avatars.githubusercontent.com/u/14868727?v=4)](https://github.com/degangliu "degangliu (1 commits)")

---

Tags

sdktencentyunqcloud

### Embed Badge

![Health badge](/badges/tencentyun-cos-php-sdk/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[async-aws/s3

S3 client, part of the AWS SDK provided by AsyncAws.

5714.0M32](/packages/async-aws-s3)[tencentyun-api/qcloudapi-sdk-php

php sdk for qcloudapi

10948.9k](/packages/tencentyun-api-qcloudapi-sdk-php)[azure-oss/storage

Azure Blob Storage PHP SDK

37985.0k5](/packages/azure-oss-storage)[yangyifan/upload

上传 SDK for Laravel

12422.6k3](/packages/yangyifan-upload)[platinumpixs/aws-symfony2-bundle

A simple Symfony 2 bundle for including the AWS SDK for PHP.

1274.3k1](/packages/platinumpixs-aws-symfony2-bundle)

PHPackages © 2026

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