Download the PHP package huaweicloud/huaweicloud-sdk-php without Composer
On this page you can find all versions of the php package huaweicloud/huaweicloud-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download huaweicloud/huaweicloud-sdk-php
More information about huaweicloud/huaweicloud-sdk-php
Files in huaweicloud/huaweicloud-sdk-php
Package huaweicloud-sdk-php
Short Description Huawei Cloud SDK for PHP
License Apache-2.0
Informations about the package huaweicloud-sdk-php
English | 简体中文
Huawei Cloud Php Software Development Kit (Php SDK)
The Huawei Cloud Php SDK allows you to easily work with Huawei Cloud services such as Elastic Compute Service (ECS) and Virtual Private Cloud(VPC) without the need to handle API related tasks.
This document introduces how to obtain and use Huawei Cloud Php SDK.
Requirements
-
To use Huawei Cloud Php SDK, you must have Huawei Cloud account as well as the Access Key (AK) and Secret key (SK) of the Huawei Cloud account. You can create an Access Key in the Huawei Cloud console. For more information, see My Credentials.
-
To use Huawei Cloud Php SDK to access the APIs of specific service, please make sure you do have activated the service in Huawei Cloud console if needed.
- Huawei Cloud Php SDK requires PHP 5.6, PHP6, PHP7 , but not support PHP8. Please run command
php --version
to check the version of Php before run php sdk code.
Install Php SDK
The recommended way to install SDK is with Composer.
Composer is a dependency management tool for Php which allows you to declare the dependencies your project needs and installs them into your project.
After installing, you need to require Composer's autoloader:
You can get the SDK version information through SDK center or Packagist.
Code example
- The following example shows how to query a list of IAM in a specific region, you need to substitute your real
{Service}Client
forIamClient
in actual use. - Substitute the values for
{your ak string}
,{your sk string}
,{your endpoint string}
and{your domain id}
.
Online Debugging
API Explorer provides api retrieval, SDK samples and online debugging, supports full fast retrieval, visual debugging, help document viewing, and online consultation.
Changelog
Detailed changes for each released version are documented in the CHANGELOG.md.
User Manual :top:
- 1. Client Configuration
- 1.1 Default Configuration
- 1.2 Network Proxy
- 1.3 Timeout Configuration
- 1.4 SSL Certification
- 2. Credentials Configuration
- 2.1 Use Permanent AK&SK
- 2.2 Use Temporary AK&SK
- 3. Client Initialization
- 3.1 Initialize the client with specified Endpoint
- 4. Send Requests and Handle Responses
- 4.1 Exceptions
- 5. Use Asynchronous Client
- 6. Troubleshooting
- 6.1 Access Log
- 6.2 Original HTTP Listener
1. Client Configuration :top:
1.1 Default Configuration :top:
1.2 Network Proxy :top:
1.3 Timeout Configuration :top:
1.4 SSL Certification :top:
2. Credentials Configuration :top:
There are two types of Huawei Cloud services, regional
services and global
services.
Global services only contain IAM.
For regional
services' authentication, project_id is required.
For global
services' authentication, domain_id is required.
Parameter description:
ak
is the access key ID for your account.sk
is the secret access key for your account.project_id
is the ID of your project depending on your region which you want to operate.domain_id
is the account ID of Huawei Cloud.security_token
is the security token when using temporary AK/SK.
2.1 Use Permanent AK&SK :top:
2.2 Use Temporary AK&SK :top:
It's required to obtain temporary AK&SK and security token first, which could be obtained through permanent AK&SK or through an agency.
-
Obtaining a temporary access key and security token through token, you could refer to document: https://support.huaweicloud.com/en-us/api-iam/iam_04_0002.html . The API mentioned in the document above corresponds to the method of
CreateTemporaryAccessKeyByToken
in IAM SDK. - Obtaining a temporary access key and security token through an agency, you could refer to
document: https://support.huaweicloud.com/en-us/api-iam/iam_04_0101.html . The API mentioned in the document above
corresponds to the method of
CreateTemporaryAccessKeyByAgency
in IAM SDK.
3. Client Initialization :top:
3.1 Initialize the {Service}Client with specified Endpoint :top:
where:
$endpoint
: varies by services and regions, see Regions and Endpoints to obtain correct endpoint.
4. Send Requests and Handle Responses :top:
4.1 Exceptions :top:
Level 1 | Notice | Level 2 | Notice |
---|---|---|---|
ConnectionException | Connection error | HostUnreachableException | Host is not reachable |
SslHandShakeException | SSL certification error | ||
RequestTimeoutException | Request timeout | CallTimeoutException | timeout for single request |
RetryOutageException | no response after retrying | ||
ServiceResponseException | service response error | ServerResponseException | server inner error, http status code: [500,] |
ClientRequestException | invalid request, http status code: [400? 500) |
5. Use Asynchronous Client :top:
6. Troubleshooting :top:
SDK supports Access
log and Debug
log which could be configured manually.
6.1 Access Log :top:
SDK supports print access log which could be enabled by manual configuration, the log could be output to the console or specified files.
For example:
where:
withFileLogger
:$logPath
: log file path.$logLevel
: log level, default is INFO.$logMaxFiles
: count of log file, default is 5.
withStreamLogger
:$stream
: stream object, default is sys.stdout.$logLevel
: log level, default is INFO.
After enabled log, the SDK will print the access log by default, every request will be recorded to the console like:
The format of access log is:
6.2 Original HTTP Listener :top:
In some situation, you may need to debug your http requests, original http request and response information will be needed. The SDK provides a listener function to obtain the original encrypted http request and response information.
:warning: Warning: The original http log information is used in debugging stage only, please do not print the original http header or body in the production environment. These log information is not encrypted and contains sensitive data such as the password of your ECS virtual machine, or the password of your IAM user account, etc. When the response body is binary content, the body will be printed as "***" without detailed information.
where:
HttpHandler supports method addRequestHandlers
and addResponseHandlers
.
All versions of huaweicloud-sdk-php with dependencies
guzzlehttp/guzzle Version >=6.3.0
guzzlehttp/psr7 Version >=1.4.2
guzzlehttp/promises Version >=1.3.1
psr/http-message Version >=1.0.1
monolog/monolog Version >=2.4.0 || <= 2.9.0