Skip to content

Commit 2292ecc

Browse files
authored
improved docs (#183)
1 parent d4df3b5 commit 2292ecc

27 files changed

+289
-289
lines changed

README-EN.md

-170
This file was deleted.

README-zh-CN.md

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
[English](/README.md) | 简体中文
2+
3+
4+
<p align="center">
5+
<a href=" https://www.alibabacloud.com"><img src="https://aliyunsdk-pages.alicdn.com/icons/Aliyun.svg"></a>
6+
</p>
7+
8+
<h1 align="center">Alibaba Cloud Client for PHP</h1>
9+
10+
<p align="center">
11+
<a href="https://packagist.org/packages/alibabacloud/client"><img src="https://poser.pugx.org/alibabacloud/client/v/stable" alt="Latest Stable Version"></a>
12+
<a href="https://packagist.org/packages/alibabacloud/client"><img src="https://poser.pugx.org/alibabacloud/client/v/unstable" alt="Latest Unstable Version"></a>
13+
<a href="https://packagist.org/packages/alibabacloud/client"><img src="https://poser.pugx.org/alibabacloud/client/composerlock" alt="composer.lock"></a>
14+
<a href="https://packagist.org/packages/alibabacloud/client"><img src="https://poser.pugx.org/alibabacloud/client/downloads" alt="Total Downloads"></a>
15+
<a href="https://packagist.org/packages/alibabacloud/client"><img src="https://poser.pugx.org/alibabacloud/client/license" alt="License"></a>
16+
<br/>
17+
<a href="https://codecov.io/gh/aliyun/openapi-sdk-php-client"><img src="https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg" alt="codecov"></a>
18+
<a href="https://scrutinizer-ci.com/g/aliyun/openapi-sdk-php-client"><img src="https://scrutinizer-ci.com/g/aliyun/openapi-sdk-php-client/badges/quality-score.png" alt="Scrutinizer Code Quality"></a>
19+
<a href="https://travis-ci.org/aliyun/openapi-sdk-php-client"><img src="https://travis-ci.org/aliyun/openapi-sdk-php-client.svg?branch=master" alt="Travis Build Status"></a>
20+
<a href="https://ci.appveyor.com/project/aliyun/openapi-sdk-php-client/branch/master"><img src="https://ci.appveyor.com/api/projects/status/699v083woth7mj85/branch/master?svg=true" alt="Appveyor Build Status"></a>
21+
<a href="https://scrutinizer-ci.com/code-intelligence"><img src="https://scrutinizer-ci.com/g/aliyun/openapi-sdk-php-client/badges/code-intelligence.svg" alt="Code Intelligence Status"></a>
22+
</p>
23+
24+
25+
Alibaba Cloud Client for PHP 是帮助 PHP 开发者管理凭据、发送请求的客户端工具,[Alibaba Cloud SDK for PHP][SDK] 由本工具提供底层支持。
26+
27+
28+
## 在线示例
29+
[API Explorer](https://api.aliyun.com) 提供在线调用阿里云产品,并动态生成 SDK 代码和快速检索接口等能力,能显著降低使用云 API 的难度。
30+
31+
32+
## 先决条件
33+
您的系统需要满足[先决条件](/docs/zh-CN/0-Prerequisites.md),包括 PHP> = 5.5。 我们强烈建议使用cURL扩展,并使用TLS后端编译cURL 7.16.2+。
34+
35+
36+
## 安装依赖
37+
如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally),请直接在项目目录中运行以下内容来安装 Alibaba Cloud Client for PHP 作为依赖项:
38+
```
39+
composer require alibabacloud/client
40+
```
41+
> 一些用户可能由于网络问题无法安装,可以尝试切换 Composer 镜像地址。
42+
43+
请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。
44+
45+
46+
## 快速使用
47+
在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)
48+
49+
### 创建客户端
50+
```php
51+
<?php
52+
53+
use AlibabaCloud\Client\AlibabaCloud;
54+
55+
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
56+
```
57+
58+
### ROA 请求
59+
```php
60+
<?php
61+
62+
use AlibabaCloud\Client\AlibabaCloud;
63+
use AlibabaCloud\Client\Exception\ClientException;
64+
use AlibabaCloud\Client\Exception\ServerException;
65+
66+
try {
67+
$result = AlibabaCloud::roa()
68+
->regionId('cn-hangzhou') // 指定请求的区域,不指定则使用客户端区域、默认区域
69+
->product('CS') // 指定产品
70+
->version('2015-12-15') // 指定产品版本
71+
->action('DescribeClusterServices') // 指定产品接口
72+
->serviceCode('cs') // 设置 ServiceCode 以备寻址,非必须
73+
->endpointType('openAPI') // 设置类型,非必须
74+
->method('GET') // 指定请求方式
75+
->host('cs.aliyun.com') // 指定域名则不会寻址,如认证方式为 Bearer Token 的服务则需要指定
76+
->pathPattern('/clusters/[ClusterId]/services') // 指定ROA风格路径规则
77+
->withClusterId('123456') // 为路径中参数赋值,方法名:with + 参数
78+
->request(); // 发起请求并返回结果对象,请求需要放在设置的最后面
79+
80+
print_r($result->toArray());
81+
82+
} catch (ClientException $exception) {
83+
print_r($exception->getErrorMessage());
84+
} catch (ServerException $exception) {
85+
print_r($exception->getErrorMessage());
86+
}
87+
```
88+
89+
### RPC 请求
90+
```php
91+
<?php
92+
93+
use AlibabaCloud\Client\AlibabaCloud;
94+
use AlibabaCloud\Client\Exception\ClientException;
95+
use AlibabaCloud\Client\Exception\ServerException;
96+
97+
try {
98+
$result = AlibabaCloud::rpc()
99+
->product('Cdn')
100+
->version('2014-11-11')
101+
->action('DescribeCdnService')
102+
->method('POST')
103+
->request();
104+
105+
print_r($result->toArray());
106+
107+
} catch (ClientException $exception) {
108+
print_r($exception->getErrorMessage());
109+
} catch (ServerException $exception) {
110+
print_r($exception->getErrorMessage());
111+
}
112+
```
113+
114+
115+
## 文档
116+
* [先决条件](/docs/zh-CN/0-Prerequisites.md)
117+
* [安装](/docs/zh-CN/1-Installation.md)
118+
* [客户端](/docs/zh-CN/2-Client.md)
119+
* [请求](/docs/zh-CN/3-Request.md)
120+
* [结果](/docs/zh-CN/4-Result.md)
121+
* [区域](/docs/zh-CN/5-Region.md)
122+
* [域名](/docs/zh-CN/6-Host.md)
123+
* [SSL 验证](/docs/zh-CN/7-Verify.md)
124+
* [调试](/docs/zh-CN/8-Debug.md)
125+
* [日志](/docs/zh-CN/9-Log.md)
126+
* [测试](/docs/zh-CN/10-Test.md)
127+
128+
129+
## 问题
130+
[提交 Issue](https://github.com/aliyun/openapi-sdk-php-client/issues/new/choose),不符合指南的问题可能会立即关闭。
131+
132+
133+
## 发行说明
134+
每个版本的详细更改记录在[发行说明](/CHANGELOG.md)中。
135+
136+
137+
## 贡献
138+
提交 Pull Request 之前请阅读[贡献指南](/CONTRIBUTING.md)
139+
140+
141+
## 相关
142+
* [阿里云服务 Regions & Endpoints][endpoints]
143+
* [OpenAPI Explorer][open-api]
144+
* [Packagist][packagist]
145+
* [Composer][composer]
146+
* [Guzzle中文文档][guzzle-docs]
147+
* [最新源码][latest-release]
148+
149+
150+
## 许可证
151+
[Apache-2.0](/LICENSE.md)
152+
153+
版权所有 1999-2019 阿里巴巴集团
154+
155+
156+
[SDK]: https://github.com/aliyun/openapi-sdk-php/blob/master/README.md
157+
[open-api]: https://api.aliyun.com
158+
[latest-release]: https://github.com/aliyun/openapi-sdk-php-client
159+
[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html
160+
[composer]: https://getcomposer.org
161+
[packagist]: https://packagist.org/packages/alibabacloud/sdk
162+
[home]: https://home.console.aliyun.com
163+
[aliyun]: https://www.aliyun.com
164+
[regions]: https://help.aliyun.com/document_detail/40654.html
165+
[endpoints]: https://developer.aliyun.com/endpoints
166+
[cURL]: http://php.net/manual/zh/book.curl.php
167+
[OPCache]: http://php.net/manual/zh/book.opcache.php
168+
[xdebug]: http://xdebug.org
169+
[OpenSSL]: http://php.net/manual/zh/book.openssl.php
170+
[client]: https://github.com/aliyun/openapi-sdk-php-client

0 commit comments

Comments
 (0)