shaozeming / aliyun-oss
继承阿里云Oss composer 包最新版本进行封装的composer package,整理配置便于管理
Installs: 2 136
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- aliyuncs/oss-sdk-php: ^2.3
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-12-22 14:14:42 UTC
README
同胞兄弟
- ShaoZeMing/aliyun-vod 阿里云点播
- ShaoZeMing/aliyun-sts 阿里云STS
- ShaoZeMing/aliyun-core 阿里云接口Core核心包
- ShaoZeMing/aliyun-oss 阿里云OSS
- 待续...
Installing
$ composer require shaozeming/aliyun-oss -v
configuration
拷贝项目下src/config.php
到你项目中,进行配置其中oss。
配置示例代码:
return [ /** * oss 配置 */ 'oss' => [ 'AccessKeyID' => 'LT********cgJFsp', 'AccessKeySecret' => 'fNcK*************d6Gn', 'endpoint' => 'oss-cn-beijing.aliyuncs.com', 'bucket' => 'miji***a365', // 'is_cname' => false, // 是否使用自己绑定域名 'is_ssl' => false, // 是否使用https 'timeout' => 3600, // 授权访问默认时间 ] ];
Example
- 由于官方提供了composer 包,本包只对配置文件进行统一整理,和其他几个项目共同配置,并继承了官方核心服务接口,你可以参考官方文档对应方法使用。
- 对照官方文档地址:https://help.aliyun.com/document_detail/32101.html?spm=a2c4g.11174283.6.749.32877da2BkSiov
use ShaoZeMing\AliOss\Services\OSSService; try { $oss = new OSSService($config); $result = $oss->createBucket('shaozeming'); // 创建Bucket // $bucket= " <yourBucketName>"; // $object = "<yourObjectName>"; // $content = "Hi, OSS."; // $result = $oss->putObject($bucket,$object,$content); // 上传文件 // ..... print_r($result); return $result; } catch (OssException $e) { $err = "Error : 错误:" . $e->getMessage(); echo $err . PHP_EOL; } catch (\Exception $e) { // $err = "Error : 错误:" . $e->getMessage(); echo $err . PHP_EOL; }
License
MIT