2022-04-06 11:03:32 -07:00
< ? php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[s3.php.create_client.complete]
// snippet-start:[s3.php.create_client.import]
require 'vendor/autoload.php' ;
use Aws\S3\S3Client ;
use Aws\Exception\AwsException ;
// snippet-end:[s3.php.create_client.import]
/**
* Creating an Amazon S3 client.
*
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
// snippet-start:[s3.php.create_client.main]
// snippet-start:[s3.php.create_client.client]
//Create an S3Client
$s3 = new Aws\S3\S3Client ([
2023-08-29 12:04:24 -05:00
'region' => 'us-east-2' // Since version 3.277.10 of the SDK,
]); // the 'version' parameter defaults to 'latest'.
2022-04-06 11:03:32 -07:00
// snippet-end:[s3.php.create_client.client]
// snippet-start:[s3.php.create_client.sdk]
// The same options that can be provided to a specific client constructor can also be supplied to the Aws\Sdk class.
// Use the us-west-2 region and latest version of each client.
$sharedConfig = [
2023-08-28 13:26:52 -05:00
'region' => 'us-west-2'
2022-04-06 11:03:32 -07:00
];
// Create an SDK class used to share configuration across clients.
$sdk = new Aws\Sdk ( $sharedConfig );
// Create an Amazon S3 client using the shared configuration data.
$client = $sdk -> createS3 ();
// snippet-end:[s3.php.create_client.sdk]
// snippet-end:[s3.php.create_client.main]
// snippet-end:[s3.php.create_client.complete]