This topic describes how to install SDKs for PHP and provides sample code.

Background information


For more information about how to install the SDKs for PHP, see Quick start.

You can download the installation packages of the SDKs for PHP from the following links:


The following code provides an example on how to use Resource Management SDK for PHP to call the CreateResourceAccount operation. You can use OpenAPI Developer Portal to debug other API operations and obtain their sample code.

use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
// Construct an Alibaba Cloud client that is used to initiate requests.
// When you construct the client, specify your AccessKey ID and AccessKey secret.
AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessKeySecret>')
// Specify request parameters and initiate a request. For more information about the parameters, see API Reference.
try {
    $result = AlibabaCloud::rpc()
                          // ->scheme('https') // https | http
                                        'query' => [
                                          'RegionId' => "cn-hangzhou",
                                          'DisplayName' => "<DisplayName>",
} catch (ClientException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
    echo $e->getErrorMessage() . PHP_EOL;