Home > Backend Development > PHP Tutorial > PHP PEAR package developed for Alibaba Cloud Storage: Services_Aliyun_OSS_PHP Tutorial

PHP PEAR package developed for Alibaba Cloud Storage: Services_Aliyun_OSS_PHP Tutorial

WBOY
Release: 2016-07-20 11:15:04
Original
950 people have browsed it

Alibaba Cloud Open Storage Service OSS: used to store static resources such as images and APKs, using Alibaba Cloud bandwidth and not occupying developer server bandwidth.

Alibaba Cloud official PHP SDK:

http://aliyun.com/product/oss/#help

For this third-party library, PHP officially calls it PEAR and needs to be developed according to the PEAR standard (standard URI).

Advantages of PEAR: One-click installation to the php/lib/php directory, require to use, very convenient.

Since Alibaba Cloud’s official PHP SDK was not developed in accordance with PEAR standards and is inconvenient to use, I developed one. The installation steps are as follows:

pear channel-discover sinkcup.github.io/<span pear
pear </span><span install</span> sinkcup/<span HTTP
pear </span><span install</span> sinkcup/Services_Aliyun_OSS
Copy after login

Usage steps:

1. Register an account on Alibaba Cloud, activate OSS, and create a bucket space.

2. Demo (refer to https://github.com/sinkcup/Services_Aliyun_OSS/blob/0.0.1/tests/Services/Aliyun/OSSTest.php):

<?<span php                                                                   
</span><span require</span> Services/Aliyun/OSS.<span php;
</span><span $conf</span> = <span array</span><span (
    </span>'accessKeyId' => 'foo',
    'accessKeySecret' => 'bar',<span 
);  
</span><span $c</span> = <span new</span> Services_Aliyun_OSS('com-example-dl', <span $conf</span><span );
</span><span $headers</span> = <span array</span><span (
    </span>'Content-Type' => 'image/jpeg',<span 
);
</span><span $r</span> = <span $c</span>->put('/home/u1/2.jpg', '/2.jpg', <span $headers</span><span  );
</span><span var_dump</span>(<span $r</span><span );
</span><span $this</span>->assertArrayHasKey('internet', <span $r</span><span );
</span>?>
Copy after login

Project code: https://github.com/sinkcup/Services_Aliyun_OSS

PEAR channel: http://sinkcup.github.io/pear/

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440219.htmlTechArticleAlibaba Cloud Open Storage Service OSS: used to store static resources such as pictures and apk, using Alibaba Cloud bandwidth and not occupying Developer server bandwidth. Alibaba Cloud official PHP SDK: http://aliyun.com...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template