The Alibaba Cloud DKMS-GCS SDK for PHP lets you perform cryptographic operations and retrieve secret values using keys managed by your Key Management Service (KMS) instance.
Prerequisites
Before you begin, make sure you have:
A KMS instance that is purchased and enabled — see Purchase and enable a KMS instance
A key created in the KMS instance — see Software-protected keys or Hardware-protected keys
(Optional) A secret, if your application needs to retrieve secret values — see Create a secret
Network access from your application's runtime environment to your KMS instance VPC address:
<KMS_INSTANCE_ID>.cryptoservice.kms.aliyuncs.com
Network requirements
The setup depends on where your application runs:
Same region and VPC as the KMS instance: Connected by default, no additional configuration required.
Same region, different VPC: Associate the application's VPC with the KMS instance. See Access a KMS instance from multiple VPCs in the same region.
On-premises data center (IDC): Configure network connectivity to access the KMS instance without using domain names. See the application access FAQ.
Install the SDK
Two installation methods are available:
Method 1 (recommended): Composer — Use Composer to manage the SDK as a project dependency.
Method 2: Download source code — Download the SDK directly from GitHub.
Method 1 (recommended): Composer
Composer is the standard dependency manager for PHP. Using Composer keeps the SDK version pinned in your project and simplifies future upgrades.
Add the SDK as a dependency using either approach:
Run the Composer command in your project's root directory:
composer require alibabacloud/dkms-gcs-sdkOr add the dependency manually to your
composer.jsonfile. ReplaceSDK_VERSIONwith the version number you want to install. We recommend using the latest version of the SDK. For available versions, see the open-source repository."require": { "alibabacloud/dkms-gcs-sdk": "SDK_VERSION" }
Run the following command in your project's root directory to install the dependency:
composer installInclude the Composer autoloader in your PHP code:
require_once __DIR__ . '/vendor/autoload.php';
Method 2: Download source code
Download the SDK source code from the open-source repository, then include the SDK's autoloader in your PHP code:
require_once '/path/to/dkms-gcs-sdk/autoload.php';Replace /path/to/dkms-gcs-sdk/ with the actual path to the downloaded SDK directory.