Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Object Storage
    • All tools
      • All SDKs
      • AWS SDK for Java
      • AWS SDK for JavaScript
      • AWS SDK for Python (boto)
      • AWS SDK for .NET
      • AWS SDK for C++
      • AWS SDK for PHP
      • AWS SDK for Go
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Getting started
  • Installation
  • Setup
  • Code snippets
  1. Tools
  2. SDK
  3. AWS SDK for PHP

AWS SDK for PHP

Written by
Yandex Cloud
Updated at April 1, 2025
  • Getting started
  • Installation
  • Setup
  • Code snippets

The AWS SDK for PHP is a software development kit for integration with AWS services.

Getting startedGetting started

  1. Create a service account.

  2. Assign to the service account the roles required for your project, e.g., storage.editor for a bucket (to work with a particular bucket) or a folder (to work with all buckets in this folder). For more information about roles, see Access management with Yandex Identity and Access Management.

    To work with objects in an encrypted bucket, a user or service account must have the following roles for the encryption key in addition to the storage.configurer role:

    • kms.keys.encrypter: To read the key, encrypt and upload objects.
    • kms.keys.decrypter: To read the key, decrypt and download objects.
    • kms.keys.encrypterDecrypter: This role includes the kms.keys.encrypter and kms.keys.decrypter permissions.

    For more information, see Key Management Service service roles.

  3. Create a static access key.

    As a result, you will get the static access key data. To authenticate in Object Storage, you will need the following:

    • key_id: Static access key ID
    • secret: Secret key

    Save key_id and secret: you will not be able to get the key value again.

Note

A service account is only allowed to view a list of buckets in the folder it was created in.

A service account can perform actions with objects in buckets that are created in folders different from the service account folder. To enable this, assign the service account roles for the appropriate folder or its bucket.

InstallationInstallation

To install the AWS SDK for PHP, follow the guide on the vendor's website. We recommend using the Composer dependency manager.

SetupSetup

  1. In the .aws directory, create a file named credentials, copy the credentials you got earlier, and paste them into it:

    [default]
    aws_access_key_id = <key_ID>
    aws_secret_access_key = <secret_key>
    
  2. If using a LAMP image from Cloud Marketplace, add the HOME environment variable referring to your home folder to the Apache httpd.conf configuration file (apache2.conf for Debian and Ubuntu):

    SetEnv HOME <home_folder>
    

    For more information about the location and name of the Apache configuration file for different operating systems, see the Apache HTTP Server Wiki.

You can use the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables instead of the .aws/credentials file.

Use the Object Storage address to access storage.yandexcloud.net.

Code snippetsCode snippets

List of bucket names

Make sure to include your project path in the autoload.php file's connection string:

<?php

// We assume that the AWS SDK is installed via Composer

require "<project_path>/vendor/autoload.php";
use Aws\S3\S3Client;

$s3 = new S3Client([
    "version" => "latest",
    "endpoint" => "https://storage.yandexcloud.net",
    "region" => "ru-central1",
]);

$buckets = $s3->listBuckets();
$bucket_count = 1;

echo "<b>Well, here are your buckets:</b></br></br>";
foreach ($buckets["Buckets"] as $bucket) {
    echo $bucket_count . ". " . $bucket["Name"] . "</br>";
    $bucket_count++;
}

?>

See also the code snippets and PHP API Reference Guide in the AWS documentation.

Was the article helpful?

Previous
AWS SDK for C++
Next
AWS SDK for Go
Yandex project
© 2025 Yandex.Cloud LLC