Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Credentials for the AWS SDK for PHP Version 3 - AWS SDK for PHP

Credentials for the AWS SDK for PHP Version 3

For reference information on available credentials mechanisms for the AWS SDKs, see Credentials and access in the AWS SDKs and Tools Reference Guide.

Important

For security, we strongly recommend that you do not use the root account for AWS access. Always refer to the Security best practices in IAM in the IAM User Guide for the latest security recommendations.

Precedence of settings

When you initialize a new service client without providing any credential arguments, the SDK uses the default credential provider chain to find AWS credentials. The SDK uses the first provider in the chain that returns credentials without an error.

The AWS SDK for PHP has a series of places that it checks in order to find values for global settings and credential providers. The following is the order of precedence:

  1. Any explicit setting set in the code or on a service client itself takes precedence over anything else.

  2. Use credentials from environment variables.

    Setting environment variables is useful if you’re doing development work on a machine other than an Amazon EC2 instance.

  3. Shared config and credentials files.

    These are the same files used by other SDKs and the AWS CLI.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.