AWS SDK for PHP
The AWS SDK for PHP
Before you start
- Create a service account.
- Add the service account to a group to grant it necessary permissions.
- Create a static access key.
Installation
To install the AWS SDK for PHP, follow the instructions
Setup
-
In your home directory, create a file called
.aws/credentials
with the static key:[default] aws_access_key_id = <id> aws_secret_access_key = <secretKey>
-
If you are using a LAMP image from Marketplace, add to the Apache
httpd.conf
configuration file (for Debian and Ubuntu —apache2.conf
), theHOME
environment variable with the home directory path:SetEnv HOME <home directory path>
For more information about the location and name of the Apache configuration file for different operating systems, see the Apache HTTP Server Wiki
.
Instead of the .aws/credentials
file, you can use the AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables.
Use the storage.ai.nebius.cloud
address to access Object Storage.
Code samples
List of bucket names:
// We assume that the AWS SDK is installed via Composer
require '/path/to/vendor/autoload.php';
use Aws\S3\S3Client;
$s3 = new S3Client([
'version' => 'latest',
'endpoint' => 'https://storage.ai.nebius.cloud',
'region' => 'eu-north1',
]);
$buckets = $s3->listBuckets();
foreach ($buckets['Buckets'] as $bucket) {
echo $bucket['Name'] . "\n";
}
See also the code samples