This topic provides the download URLs of the PHP SDK packages that are required for you to use STS. This topic also describes how to use the STS SDK for PHP.

Download URLs

Use the STS SDK for PHP

namespace AlibabaCloud\Tests\Feature;
use AlibabaCloud\Sts\Sts;
use PHPUnit\Framework\TestCase;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Sts\V20150401\AssumeRole;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Exception\ClientException;
 * Class StsTest
 * @package   AlibabaCloud\Tests\Feature
class StsTest extends TestCase
     * @expectedException \AlibabaCloud\Client\Exception\ServerException
     * @expectedExceptionMessageRegExp /EntityNotExist.Role: The specified Role not exists/
     * @throws ClientException
     * @throws ServerException
    // Construct an AssumeRole request.
    public function testSts()
        // When you construct the client, set the AccessKey ID and AccessKey secret.      
        AlibabaCloud::accessKeyClient('LTAI4Ftm6BWGjEuusQzg****', 'W4ePhh5ArgySotqktAwXsSayQX****');
           // Specify the Alibaba Cloud Resource Name (ARN) of the RAM role.
           // Specify a role session name, which is used to identify the RAM user who assumes the RAM role.
           // Specify a policy to grant the returned STS token fewer permissions than those granted to the RAM role.
           // The policy that is used in this example allows read-only access to all Object Storage Service (OSS) resources.
                      "Effect": "Allow",
                      "Resource": "*"
          "Version": "1"
  • For the list of STS endpoints in different regions, see Endpoints.
  • For more information about the AssumeRole API operation, see AssumeRole.