Home > Article > Backend Development > How to simply import and use Alibaba Cloud OSSsdk in thinkPHP
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); }
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!