aliyun/aliyun-oss-php-sdk — dự án mã nguồn mở — đang có 1.0k sao GitHub. Aliyun OSS SDK for PHP
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
OSS SDK for PHP V2(alibabacloud-oss-php-sdk-v2) beta version has been released, it is a major rewrite of OSS SDK for PHP V1 (aliyun-oss-php-sdk).
V2 simplifies underlying operations such as identification authentication, automatic retry of failed requests, and error handling. It provides flexible parameter configuration methods and rich advanced operations, such as paginator, transmission managers. This comprehensively improves development efficiency and experience.
Overview
Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
Run environment
PHP 5.3+.
cURL extension.
Tips:
In Ubuntu, you can use the apt-get package manager to install the PHP cURL extension: sudo apt-get install php5-curl.
Install OSS PHP SDK
If you use the composer to manage project dependencies, run the following command in your project's root directory:
composer require aliyuncs/oss-sdk-php
You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the composer.json file.
"require": {
"aliyuncs/oss-sdk-php": "~2.0"
}
Then run composer install to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code:
require_once __DIR__ . '/vendor/autoload.php';
You can also directly download the packaged PHAR File, and
introduce the file to your code:
require_once '/path/to/oss-sdk-php.phar';
Download the SDK source code, and introduce the autoload.php file under the SDK directory to your code:
require_once '/path/to/oss-sdk/autoload.php';
Quick use
Common classes
Class
Explanation
OSS\OssClient
OSS client class. An OssClient instance can be used to call the interface.
OSS\Core\OssException
OSS Exception class . You only need to pay attention to this exception when you use the OssClient.
Initialize an OssClient
The SDK's operations for the OSS are performed through the OssClient class. The code below creates an OssClient object:
<?php
$accessKeyId = "<AccessKeyID that you obtain from OSS>";
$accessKeySecret = "<AccessKeySecret that you obtain from OSS>";
$endpoint = "<Domain that you select to access an OSS data center, such as "oss-cn-hangzhou.aliyuncs.com>";
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) {
print $e->getMessage();
}
Operations on objects
Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object:
<?php
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
$object = "<Name of the object in use. Pay attention to naming conventions>";
$content = "Hello, OSS!"; // Content of the uploaded file
try {
$ossClient->putObject($bucket, $object, $content);
} catch (OssException $e) {
print $e->getMessage();
}
Operations on buckets
Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code:
<?php
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
try {
$ossClient->createBucket($bucket);
} catch (OssException $e) {
print $e->getMessage();
}
Handle returned results
The OssClient provides the following two types of returned data from interfaces:
Put and Delete interfaces: The PUT and DELETE operations are deemed successful if null is returned by the interfaces without OSSException.
Get and List interfaces: The GET and LIST operations are deemed successful if the desired data is returned by the interfaces without OSSException. For example,
aliyun/aliyun-oss-php-sdk có 1.0k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/aliyun/aliyun-oss-php-sdk. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
aliyun/aliyun-oss-php-sdk có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho aliyun/aliyun-oss-php-sdk. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
aliyun/aliyun-oss-php-sdk còn đang phát triển không?
Commit gần nhất trên aliyun/aliyun-oss-php-sdk là 4 tháng trước (theo timestamp GitHub). Repo có 347 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
aliyun/aliyun-oss-php-sdk viết bằng ngôn ngữ gì?
aliyun/aliyun-oss-php-sdk chủ yếu viết bằng PHP. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc thêm về aliyun/aliyun-oss-php-sdk ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/aliyun/aliyun-oss-php-sdk là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc aliyun-oss-php-sdk có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về aliyun-oss-php-sdk.