ini provider - Amazon SDK for PHP
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

ini provider

Aws\Credentials\CredentialProvider::ini attempts to load credentials from the shared config and credentials files. By default, the SDK attempts to load the “default” profile from the shared Amazon credentials file located at ~/.aws/credentials. If the SDK finds the AWS_SDK_LOAD_NONDEFAULT_CONFIG environment variable, it also checks for a "default" profile in the shared Amazon config file located at ~/.aws/config.

use Aws\Credentials\CredentialProvider; use Aws\S3\S3Client; $provider = CredentialProvider::ini(); // Cache the results in a memoize function to avoid loading and parsing // the ini file on every API operation $provider = CredentialProvider::memoize($provider); $client = new S3Client([ 'region' => 'us-west-2', 'version' => '2006-03-01', 'credentials' => $provider ]);

You can use a custom profile or .ini file location by providing arguments to the function that creates the provider.

$profile = 'production'; $path = '/full/path/to/credentials.ini'; $provider = CredentialProvider::ini($profile, $path); $provider = CredentialProvider::memoize($provider); $client = new S3Client([ 'region' => 'us-west-2', 'version' => '2006-03-01', 'credentials' => $provider ]);