Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c1ce17

Browse files
wb-hx510875AxiosLeo
wb-hx510875
authored andcommitted
chore: add docs
1 parent 942a3ab commit 9c1ce17

File tree

6 files changed

+324
-0
lines changed

6 files changed

+324
-0
lines changed

‎README-CN.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[English](README.md) | 简体中文
2+
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
3+
4+
# Alibaba Cloud SDK
5+
6+
## 使用说明
7+
8+
- [Usage for PHP](./docs/php/0-Examples-CN.md)
9+
10+
## 问题
11+
12+
[Opening an Issue](https://github.com/aliyun/alibabacloud-php-sdk/issues/new),不符合指南的问题可能会立即关闭。
13+
14+
## 相关
15+
16+
- [Latest Release](https://github.com/aliyun/alibabacloud-php-sdk)
17+
18+
## 许可证
19+
20+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
21+
22+
版权所有 1999-present, 阿里巴巴集团.

‎README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
English | [简体中文](README-CN.md)
2+
3+
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
4+
5+
# Alibaba Cloud SDK
6+
7+
## Usage
8+
9+
- [Usage for PHP](./docs/php/0-Examples-EN.md)
10+
11+
## Issues
12+
13+
[Opening an Issue](https://github.com/aliyun/alibabacloud-php-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately.
14+
15+
## References
16+
17+
- [Latest Release](https://github.com/aliyun/alibabacloud-php-sdk)
18+
19+
## License
20+
21+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
22+
23+
Copyright 1999-present, Alibaba Cloud All rights reserved.

‎docs/0-Examples-CN.md‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[← 首页](../../README.md) | 快速使用[(English)](0-Examples-EN.md)
2+
3+
***
4+
5+
## 要求
6+
7+
- 要使用 Alibaba Cloud SDK for PHP,您需要一个云账号以及一对 `Access Key ID``Access Key Secret`。 请在阿里云控制台中的[AccessKey管理页面](https://usercenter.console.aliyun.com/#/manage/ak)上创建和查看您的Access Key,或者联系您的系统管理员。
8+
- 要使用 Alibaba Cloud SDK for PHP 访问某个产品的API,您需要事先在[阿里云控制台](https://home.console.aliyun.com/)中开通这个产品。
9+
- Alibaba Cloud SDK for PHP 需要 PHP >= 5.6 以上的版本。
10+
11+
## 通过 Composer 来管理项目依赖(推荐)
12+
13+
```bash
14+
# require alibabacloud/imagesearch-20200212 for example
15+
composer require alibabacloud/imagesearch-20200212
16+
```
17+
18+
# 快速使用
19+
20+
以下这个代码示例向您展示了调用 Alibaba Cloud SDK for PHP 的3个主要步骤:
21+
22+
1. 创建`Config`实例并初始化。
23+
24+
2. 创建`Client`实例并初始化。
25+
26+
3. 创建`RuntimeOptions`实例并设置运行参数。
27+
28+
4. 创建 API 请求并设置参数。
29+
30+
5. 发起请求并处理应答或异常。
31+
32+
```php
33+
namespace demo;
34+
35+
require __DIR__ . '/vendor/autoload.php';
36+
37+
use AlibabaCloud\SDK\ImageSearch\V20200212\ImageSearch;
38+
use AlibabaCloud\Tea\Rpc\Rpc\Config;
39+
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
40+
41+
$config = new Config();
42+
$config->accessKeyId = "<Access-Key-Id>";
43+
$config->accessKeySecret = "<Access-Key-Secret>";
44+
$config->regionId = "cn-shanghai";
45+
$config->endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
46+
$client = new ImageSearch($config);
47+
$request = new ImageSearch\SearchImageByNameRequest();
48+
$request->picName = 'test';
49+
50+
$runtime = new RuntimeOptions();
51+
$runtime->maxIdleConns = 3;
52+
$runtime->connectTimeout = 10000;
53+
$runtime->readTimeout = 10000;
54+
try {
55+
$response = $client->searchImageByName($request, $runtime);
56+
var_dump($response->toMap());
57+
} catch (TeaUnableRetryError $e) {
58+
var_dump($e->getMessage());
59+
var_dump($e->getErrorInfo());
60+
var_dump($e->getLastException());
61+
var_dump($e->getLastRequest());
62+
}
63+
```
64+
65+
***
66+
[← 首页](../../README.md) | 快速使用[(English)](0-Examples-EN.md)

‎docs/0-Examples-EN.md‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[← Home](../../README.md) | Examples[(中文)](0-Examples-CN.md)
2+
3+
***
4+
5+
## Requirements
6+
7+
- To use Alibaba Cloud SDK for PHP, you must have an Alibaba Cloud account as well as an `AccessKey ID` and an `AccessKey Secret`. Create and view your AccessKey on the [RAM console](https://ram.console.aliyun.com "RAM console") or contact your system administrator.
8+
- To use the Alibaba Cloud SDK for PHP to access the APIs of a product, you must first activate the product on the [Alibaba Cloud console](https://home.console.aliyun.com) if required.
9+
- The Alibaba Cloud PHP SDK requires PHP 5.6 or later.
10+
11+
## Installation
12+
13+
If you use `Composer` to manage PHP libraries
14+
15+
```bash
16+
# require alibabacloud/imagesearch-20200212 for example
17+
composer require alibabacloud/imagesearch-20200212
18+
```
19+
20+
## Quick Examples
21+
22+
The following code example shows the three main steps to use Alibaba Cloud SDK for PHP :
23+
24+
1. Create and initialize a `Config` instance.
25+
26+
2. Create and initialize a `Client` instance.
27+
28+
3. Create and set up parameters `RuntimeOptions` instance.
29+
30+
4. Create an API request and set parameters.
31+
32+
5. Initiate the request and handle the response or exceptions.
33+
34+
```php
35+
namespace demo;
36+
37+
require __DIR__ . '/vendor/autoload.php';
38+
39+
use AlibabaCloud\SDK\ImageSearch\V20200212\ImageSearch;
40+
use AlibabaCloud\Tea\Rpc\Rpc\Config;
41+
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
42+
43+
$config = new Config();
44+
$config->accessKeyId = "<Access-Key-Id>";
45+
$config->accessKeySecret = "<Access-Key-Secret>";
46+
$config->regionId = "cn-shanghai";
47+
$config->endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
48+
$client = new ImageSearch($config);
49+
$request = new ImageSearch\SearchImageByNameRequest();
50+
$request->picName = 'test';
51+
52+
$runtime = new RuntimeOptions();
53+
$runtime->maxIdleConns = 3;
54+
$runtime->connectTimeout = 10000;
55+
$runtime->readTimeout = 10000;
56+
try {
57+
$response = $client->searchImageByName($request, $runtime);
58+
var_dump($response->toMap());
59+
} catch (TeaUnableRetryError $e) {
60+
var_dump($e->getMessage());
61+
var_dump($e->getErrorInfo());
62+
var_dump($e->getLastException());
63+
var_dump($e->getLastRequest());
64+
}
65+
```
66+
67+
***
68+
[← Home](../../README.md) | Examples[(中文)](0-Examples-CN.md)

‎docs/1-Client-CN.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[← Examples](0-Examples-CN.md) | 客户端与凭证[(English)](1-Client-EN.md) | [首页 →](../../README-CN.md)
2+
***
3+
4+
### 使用 AccessKey 调用
5+
6+
```java
7+
8+
use AlibabaCloud\Tea\Rpc\Rpc\Config;
9+
10+
$config = new Config();
11+
$config->accessKeyId = "<Access-Key-Id>";
12+
$config->accessKeySecret = "<Access-Key-Secret>";
13+
$client = new ImageSearch($config);
14+
15+
```
16+
17+
### 使用默认凭证提供链
18+
19+
默认凭证提供程序链查找可用的凭证,寻找顺序如下:
20+
21+
1. 环境凭证
22+
23+
在环境变量里寻找环境凭证,如果定义了 `ALIBABA_CLOUD_ACCESS_KEY_ID``ALIBABA_CLOUD_ACCESS_KEY_SECRET` 环境变量且不为空,程序将使用它们创建默认凭证。
24+
25+
2. 配置文件
26+
27+
如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的客户端。默认文件可以不存在,但解析错误会抛出异常。 客户端名称不分大小写,若客户端同名,后者会覆盖前者。也可以手动加载指定文件: `AlibabaCloud::load('/data/credentials', 'vfs://AlibabaCloud/credentials', ...);` 不同的项目、工具之间可以共用这个配置文件,因为超出项目之外,也不会被意外提交到版本控制。Windows 上可以使用环境变量引用到主目录 %UserProfile%。类 Unix 的系统可以使用环境变量 $HOME 或 ~ (tilde)。 可以通过定义 `ALIBABA_CLOUD_CREDENTIALS_FILE` 环境变量修改默认文件的路径。
28+
29+
```ini
30+
[default] # 默认客户端
31+
enable = true # 启用,没有该选项默认启用
32+
type = access_key # 认证方式为 access_key
33+
access_key_id = foo # Key
34+
access_key_secret = bar # Secret
35+
region_id = cn-hangzhou # 非必填,区域
36+
debug = true # 非必填,Debug模式会在CLI下输出详细信息
37+
timeout = 0.2 # 非必填,超时时间,>1为单位为秒, <1自动乘1000转为毫秒
38+
connect_Timeout = 0.03 # 非必填,连接超时时间,同超时时间
39+
cert_file = /path/server.pem # 非必填,证书文件
40+
cert_password = password # 非必填,证书密码,没有密码可不填
41+
proxy = tcp://localhost:8125 # 非必填,总代理
42+
proxy_http = tcp://localhost:8125 # 非必填,HTTP代理
43+
proxy_https = tcp://localhost:9124 # 非必填,HTTPS代理
44+
proxy_no = .mit.edu,foo.com # 非必填,代理忽略的域名
45+
46+
[client1] # 命名为 `client1` 的客户端
47+
type = ecs_ram_role # 认证方式为 ecs_ram_role
48+
role_name = EcsRamRoleTest # Role Name
49+
#..................................# 其他配置忽略同上
50+
51+
[client2] # 命名为 `client2` 的客户端
52+
enable = false # 不启用
53+
type = ram_role_arn # 认证方式为 ram_role_arn
54+
access_key_id = foo
55+
access_key_secret = bar
56+
role_arn = role_arn
57+
role_session_name = session_name
58+
#..................................# 其他配置忽略同上
59+
60+
[client3] # 命名为 `client3` 的客户端
61+
type = rsa_key_pair # 认证方式为 rsa_key_pair
62+
public_key_id = publicKeyId # Public Key ID
63+
private_key_file = /your/pk.pem # Private Key 文件
64+
#..................................# 其他配置忽略同上
65+
66+
```
67+
68+
3. 实例 RAM 角色
69+
70+
如果定义了环境变量 `ALIBABA_CLOUD_ECS_METADATA` 且不为空,程序会将该环境变量的值作为角色名称,请求 `http://100.100.100.200/latest/meta-data/ram/security-credentials/` 获取临时安全凭证,再创建一个默认客户端。
71+
72+
***
73+
[← Examples](0-Examples-CN.md) | 客户端与凭证[(English)](1-Client-EN.md) | [首页 →](../../README-CN.md)

‎docs/1-Client-EN.md‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[← Examples](0-Examples-EN.md) | Client & Credentials[(中文)](1-Client-CN.md) | [Home →](../../README.md)
2+
***
3+
4+
### Using AccessKey call
5+
6+
```java
7+
8+
use AlibabaCloud\Tea\Rpc\Rpc\Config;
9+
10+
$config = new Config();
11+
$config->accessKeyId = "<Access-Key-Id>";
12+
$config->accessKeySecret = "<Access-Key-Secret>";
13+
$client = new ImageSearch($config);
14+
15+
```
16+
17+
### Use the default credential provider chain
18+
19+
The default credential provider chain looks for available credentials, with following order:
20+
21+
1. Environment Credentials
22+
23+
Look for environment credentials in environment variable. If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and are not empty, the program will use them to create default credentials.
24+
25+
2. Credentials File
26+
27+
If there is `~/.alibabacloud/credentials` default file (Windows shows `C:\Users\USER_NAME\.alibabacloud\credentials`), the program will automatically create clients with the specified type and name. The default file may not exist, but a parse error throws an exception. The client name is case-insensitive, and if the clients have the same name, the latter will override the former. The specified files can also be loaded indefinitely: `AlibabaCloud::load('/data/credentials', 'vfs://AlibabaCloud/credentials', ...);` This configuration file can be shared between different projects and between different tools. Because it is outside the project and will not be accidentally committed to the version control. Environment variables can be used on Windows to refer to the home directory %UserProfile%. Unix-like systems can use the environment variable $HOME or ~ (tilde). The path to the default file can be modified by defining the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable.
28+
29+
```ini
30+
[default] # Default client
31+
enable = true # Enable,Enabled by default if this option not present
32+
type = access_key # Certification type: access_key
33+
access_key_id = foo # Key
34+
access_key_secret = bar # Secret
35+
region_id = cn-hangzhou # Optional,Region
36+
debug = true # Optional,Debug mode will output the details under CLI
37+
timeout = 0.2 # Optional,Time-out period. if >1, unit is seconds; if<1, unit will be converted to milliseconds by multiplying 1000 automatically
38+
connect_Timeout = 0.03 # Optional,Connection timeout, same as timeout
39+
cert_file = /path/server.pem # Optional,Certification file
40+
cert_password = password # Optional,Certification password, can be empty if no password
41+
proxy = tcp://localhost:8125 # Optional,General proxy
42+
proxy_http = tcp://localhost:8125 # Optional,HTTP proxy
43+
proxy_https = tcp://localhost:9124 # Optional,HTTPS proxy
44+
proxy_no = .mit.edu,foo.com # Optional,Ignored Domain Name by proxy
45+
46+
[client1] # Client that is named as `client1`
47+
type = ecs_ram_role # Certification type: ecs_ram_role
48+
role_name = EcsRamRoleTest # Role Name
49+
#..................................# As above, other configurations ignored.
50+
51+
[client2] # Client that is named as `client2`
52+
enable = false # Disable
53+
type = ram_role_arn # Certification type: ram_role_arn
54+
access_key_id = foo
55+
access_key_secret = bar
56+
role_arn = role_arn
57+
role_session_name = session_name
58+
#..................................# As above, other configurations ignored.
59+
60+
[client3] # Client that is named as `client3`
61+
type = rsa_key_pair # Certification type: rsa_key_pair
62+
public_key_id = publicKeyId # Public Key ID
63+
private_key_file = /your/pk.pem # Private Key file
64+
#..................................# As above, other configurations ignored.
65+
```
66+
67+
3. Instance RAM Role
68+
69+
If the environment variable `ALIBABA_CLOUD_ECS_METADATA` is defined and not empty, the program will take the value of the environment variable as the role name and request `http://100.100.100.200/latest/meta-data/ram/security-credentials/` to get the temporary Security credentials, then create a default client.
70+
71+
***
72+
[← Examples](0-Examples-EN.md) | Client & Credentials[(中文)](1-Client-CN.md) | [Home →](../../README.md)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /