php-awsHow can I use the AWS PHP SDK to manage Route53 records?
The AWS PHP SDK can be used to manage Route53 records. The following example code will list all the hosted zones in your account:
<?php
require 'vendor/autoload.php';
use Aws\Route53\Route53Client;
$client = new Route53Client([
'profile' => 'default',
'region' => 'us-east-1',
'version' => 'latest'
]);
$result = $client->listHostedZones();
foreach ($result['HostedZones'] as $zone) {
echo $zone['Name'] . "\n";
}
Output example
example.com.
Code explanation
- Require the autoloader, so that we can use the SDK:
require 'vendor/autoload.php';
- Use the
Aws\Route53\Route53Client
class to create a new client:$client = new Route53Client([ ... ]);
- Call the
listHostedZones
method on the client to list all the hosted zones in the account:$result = $client->listHostedZones();
- Iterate over the
HostedZones
array in the result and echo theName
of each:echo $zone['Name'] . "\n";
For more information, see the AWS PHP SDK documentation and the Route53 API reference.
More of Php Aws
- How can I use PHP to connect to an Amazon Aurora database?
- How do I use PHP to create a ZIP file on AWS?
- How can I use AWS and Zksync together with PHP?
- How can I use Yum to install PHP on an Amazon EC2 instance?
- How can I use an AWS SQS Worker with PHP?
- How can I use AWS WAF to secure my PHP application?
- How can I use AWS PHP SDK without credentials?
- How do I generate an AWS Signature Version 4 with PHP?
- How do I determine the version of PHP I am running on AWS?
- How can I use the AWS S3 S3Client library with PHP?
See more codes...