

# Using IAM account aliases with Amazon SDK for PHP Version 3
<a name="iam-examples-using-account-aliases"></a>

If you want the URL for your sign-in page to contain your company name or other friendly identifier instead of your Amazon Web Services account ID, you can create an alias for your Amazon Web Services account ID. If you create an Amazon Web Services account alias, your sign-in page URL changes to incorporate the alias.

The following examples show how to:
+ Create an alias using [CreateAccountAlias](https://docs.amazonaws.cn/aws-sdk-php/v3/api/api-iam-2010-05-08.html#createaccountalias).
+ List the alias associated with the Amazon Web Services account using [ListAccountAliases](https://docs.amazonaws.cn/aws-sdk-php/v3/api/api-iam-2010-05-08.html#listaccountaliases).
+ Delete an alias using [DeleteAccountAlias](https://docs.amazonaws.cn/aws-sdk-php/v3/api/api-iam-2010-05-08.html#deleteaccountalias).

All the example code for the Amazon SDK for PHP is available [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code).

## Credentials
<a name="examplecredentials"></a>

Before running the example code, configure your Amazon credentials, as described in [Authenticating with Amazon using Amazon SDK for PHP Version 3](credentials.md). Then import the Amazon SDK for PHP, as described in [Installing the Amazon SDK for PHP Version 3](getting-started_installation.md).

## Create an alias
<a name="create-an-alias"></a>

 **Imports** 

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
use Aws\Iam\IamClient;
```

 **Sample Code** 

```
$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);

try {
    $result = $client->createAccountAlias(array(
        // AccountAlias is required
        'AccountAlias' => 'string',
    ));
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}
```

## List account aliases
<a name="list-account-aliases"></a>

 **Imports** 

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
use Aws\Iam\IamClient;
```

 **Sample Code** 

```
$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);

try {
    $result = $client->listAccountAliases();
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}
```

## Delete an alias
<a name="delete-an-alias"></a>

 **Imports** 

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
use Aws\Iam\IamClient;
```

 **Sample Code** 

```
$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);

try {
    $result = $client->deleteAccountAlias([
        // AccountAlias is required
        'AccountAlias' => 'string',
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}
```