aws/aws-sdk-php — pull request #413 by mtdowling (2014-11-26 23:27:50+00:00)
Title: Adding credential providers and refactoring creds.

This commit adds a concept of credential providers, or functions that
when called return credentials or return null. This commit introduces
several credential providers that allow you to compose conditional
credential loading logic based on the environment the code is run in.

Addresses #371

Some examples:

```php
use Aws\Common\Credentials\Provider;

// Create a provider function that returns credentials.
// Load from environment variables.
$provider = Provider::env();
$credentials = $provider();

// Load from an ini file using the default profile
$provider = Provider::ini();
$credentials = $provider();

// Load from an ini file using a specific profile
$provider = Provider::ini('foo');
$credentials = $provider();

// Loads from hardcoded credentials
$provider = Provider::hardcoded('key', 'secret');
$credentials = $provider();

// Loads from a chain of providers (does not throw if they all return null)
$chainProvider = Provider::chain([
Provider::env(), // Try the environment first
Provider::ini('foo'), // Try a specific profile from the ini file
Provider::ini(), // try the default profile
Provider::chain([Provider::instanceProfile()]) // You can even put chains inside of chains!
]);
$credentials = $chainProvider(); // might return null!

// fromChain() executes provides in order until one returns credentials.
// If not credentials are found an exception is thrown.
$credentials = Provider::fromChain([
Provider::env(),
Provider::ini(),
Provider::instanceProfile($config)
]);
```

Credentials are then passed as normally to a client via the factory method:

```php
$s3 = Aws\S3\S3Client::factory([
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => $credentials
]);
```