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\Route53Clientclass to create a new client:$client = new Route53Client([ ... ]); - Call the
listHostedZonesmethod on the client to list all the hosted zones in the account:$result = $client->listHostedZones(); - Iterate over the
HostedZonesarray in the result and echo theNameof each:echo $zone['Name'] . "\n";
For more information, see the AWS PHP SDK documentation and the Route53 API reference.
More of Php Aws
- 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 do I generate an AWS Signature Version 4 with PHP?
- How can I use the AWS S3 S3Client library with PHP?
- How can I connect to an AWS MySQL database using PHP?
- How can I use AWS Textract with PHP?
- How can I connect to Amazon Web Services (AWS) S3 using PHP?
See more codes...