Skip to content

evan-klein/zone-file

Repository files navigation

Zone File

A simple PHP class for generating DNS zone files.

Features

Example

<?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();

?>

Documentation