Download the PHP package chinac/cos-php-sdk without Composer

On this page you can find all versions of the php package chinac/cos-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cos-php-sdk

Chinac COS SDK for PHP

概述

华云对象存储(Chinac Object Storage Service,简称COS),是华云对外提供的海量、安全、低成本、高可靠的云存储服务。用户可以通过调用API,在任何应用、任何时间、任何地点上传和下载数据,也可以通过用户Web控制台对数据进行简单的管理。COS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。

运行环境

提示:

安装方法

  1. 如果您通过composer管理您的项目依赖,可以在你的项目根目录运行:

    $ composer require chinacos/cos-php-sdk

    或者在你的composer.json中声明对COS-PHP-SDK的依赖:

    "require": {
        "chinacos/cos-sdk-php": "~2.0"
    }

    然后通过composer install安装依赖。composer安装完成后,在您的PHP代码中引入依赖即可:

    require_once __DIR__ . '/vendor/autoload.php';
  2. 您也可以直接下载已经打包好的[phar文件][releases-page],然后在你 的代码中引入这个文件即可:

    require_once '/path/to/cos-sdk-php.phar';
  3. 下载SDK源码,在您的代码中引入SDK目录下的autoload.php文件:

    require_once '/path/to/cos-sdk/autoload.php';

快速使用

常用类

类名 解释
COS\CosClient COS客户端类,用户通过CosClient的实例调用接口
COS\Core\CosException COS异常类,用户在使用的过程中,只需要注意这个异常

CosClient初始化

SDK的COS操作通过CosClient类完成的,下面代码创建一个CosClient对象:

文件操作

文件(又称对象,Object)是COS中最基本的数据单元,您可以把它简单地理解为文件,用下面代码可以实现一个Object的上传:

存储空间操作

存储空间(又称Bucket)是一个用户用来管理所存储Object的存储空间,对于用户来说是一个管理Object的单元,所有的Object都必须隶属于某个Bucket。您可以按照下面的代码新建一个Bucket:

返回结果处理

CosClient提供的接口返回返回数据分为两种:

上面代码中的$bucketListInfo的数据类型是 COS\Model\BucketListInfo

运行Sample程序

  1. 设置环境变量:COS_ACCESS_KEY_ID, COS_ACCESS_KEY_SECRET, COS_ENDPOINT, COS_TEST_BUCKET
  2. 修改 samples/Config.php, 补充配置信息
  3. 执行 cd samples/ && php RunAll.php

运行单元测试

  1. 修改 tests/COS/Tests/Config.php, 补充配置信息
  2. 执行 ./vendor/bin/phpunit tests/COS/Tests/

联系我们

华云COS官方网站


All versions of cos-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chinac/cos-php-sdk contains the following files

Loading the files please wait ....