A simple PHP class for generating DNS zone files.
- Supports A, AAAA, CNAME, TXT, MX, SRV, and NS records
- Compatible with:
- Shell script to deploy to Route 53
- RFC 1035/RFC 1034 compliant-ish
<?php
require('ZoneFile.php');
$zone_file = new \evan_klein\zone_file\ZoneFile('example.com.', 180);
$zone_file->addA('www', '93.184.216.34', 120);
$zone_file->addAAAA('www', '2606:2800:220:1:248:1893:25c8:1946', 120);
echo $zone_file->output();
?>
The code above generates the output below:
$ORIGIN example.com.
$TTL 180
;example.com.
www 120 IN A 93.184.216.34
www 120 IN AAAA 2606:2800:220:1:248:1893:25c8:1946
You can also chain commands like this:
<?php
require('ZoneFile.php');
$zone_file = new \evan_klein\zone_file\ZoneFile('example.com.', 180);
echo $zone_file->addA('www', '93.184.216.34', 120)
->addAAAA('www', '2606:2800:220:1:248:1893:25c8:1946', 120)
->output();
?>