In this article, we will review the basics for using VPSA Object Storage with AWS S3 PHP SDK. aws-sdk-php is the official AWS S3 SDK for PHP.
Prerequisites
- Zadara VPSA Object Storage deployed in a location of your choice.
- PHP Composer
- aws/aws-sdk-php composer package
Connectivity information
For Object Storage connectivity, it is required to gather the following information from the VPSA Object Storage management UI:
- VPSA Object Storage Endpoint
- VPSA Object Storage region.
- S3 API Access Key/Secret Key
From the VPSA Object Storage GUI, navigate to the User Information section (top right corner, by clicking the logged in username).
Example
#!/usr/bin/env php
<?php
// require the AWS SDK for PHP library
require 'vendor/autoload.php';
use Aws\S3\S3Client;
// Establish connection to ZIOS with an S3 client.
$client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => '<VPSA Object Storage Region i.e. us-east-01>',
'endpoint' => '<VPSA Object Storage Endpoint i.e. https://vsa-00000001-cloud-01.zadarazios.com>',
'credentials' => [
'key' => '<S3_Access_Key>',
'secret' => '<S3_Secret_Key>',
]
]);
// List containers
$buckets = $client->listBuckets();
foreach ($buckets['Buckets'] as $bucket){
echo "{$bucket['Name']}\n";
};
?>
Got a question? We love to help, send us a mail to support@zadarastorage.com