Home > Backend Development > PHP Tutorial > How to simply import and use Alibaba Cloud OSSsdk in thinkPHP

How to simply import and use Alibaba Cloud OSSsdk in thinkPHP

不言
Release: 2023-03-25 16:26:01
Original
2270 people have browsed it

This article mainly introduces how thinkPHP simply imports and uses Alibaba Cloud OSSsdk. It briefly explains the PHP sdk download address of Alibaba Cloud OSS and how thinkPHP imports and uses OSSsdk. Friends who need it can refer to it

The example in this article describes how thinkPHP simply imports and uses Alibaba Cloud OSSsdk. Share it with everyone for your reference. The details are as follows:

It is absolutely ok to follow this. In ThinkPHP, third-party libraries are placed under the ThinkPHP/Library/Vendor/ path.

1. Download OSS PHP SDK: https://help.aliyun.com/document_detail/oss/sdk/php-sdk/install.html

2. In ThinkPHP/Library/Vendor Create an OSS directory under / and copy the decompressed SDK to this directory:

Adk files and directories under the ThinkPHP/Library/Vendor/OSS/ directory in ThinkPHP:

samples
src
tests
.coveralls.yml
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
autoload.php
composer.json
.....

public function edit(){
 Vendor('OSS.autoload');//引入文件
 $accessKeyId = ""; 
 $accessKeySecret = "";
 $endpoint = "";
 try {
  $ossClient = new \OSS\OssClient($accessKeyId, $accessKeySecret, $endpoint);
 } catch (OssException $e) {
  print $e->getMessage();
 }
 var_dump($ossClient);
}
Copy after login

Related Recommended:

thinkphp form uploads files and saves the file path to the database

Thinkphp combines AJAX long polling to implement PC and APP push


The above is the detailed content of How to simply import and use Alibaba Cloud OSSsdk in thinkPHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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