2017 © Pedro Peláez
 

library dns-zone-configurator

Php library for parsing and editing dns zones files programmatically with high level abstraction.

image

ltd-beget/dns-zone-configurator

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  • Tuesday, August 15, 2017
  • by Voksiv
  • Repository
  • 5 Watchers
  • 11 Stars
  • 3,440 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 21 Versions
  • 4 % Grown

The README.md

dns-zone-configurator

Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage Build Status Documentation Documentation License MIT, (*1)

Php library for parsing and editing dns zones files programmatically with high level abstraction., (*2)

Installation

composer require ltd-beget/dns-zone-configurator

Usage

<?php
    use LTDBeget\dns\configurator\Zone;

    require './vendor/autoload.php';

    // get you zone file content
    $content = file_get_contents(__DIR__."/dns/zones/zone.conf");

    // make zone object from plain content
    $zone = Zone::fromString("voksiv.ru.", $content);

    // iterate via nodes of zone, where Node is group of resource records with same name
    foreach ($zone->iterateNodes() as $node) {
        $node->getName();
        $node->getZone();
    }

    // or get concrete node
    if($zone->isNodeExist("node.name")) {
        $node = $zone->getNode("node.name");
        $node->getName();
        $node->getZone();
    }

    // also you can iterate via resource records in zone
    foreach ($zone->iterateRecords() as $record) {
        $record->getType();
        $record->getTtl();
        $record->getNode();
    }
    // or iterate in node
    if($zone->isNodeExist("node.name")) {
        $node = $zone->getNode("node.name");
        foreach ($node->iterateRecords() as $record) {
            $record->getType();
            $record->getTtl();
            $record->getNode();
        }
    }
    // or iterate only concrete records in zone or node
    foreach ($zone->iterateA() as $record) {
        $record->getAddress();
        $record->getType();
        $record->getTtl();
        $record->getNode();
    }

    // all records can be modified
    foreach ($zone->iterateNs() as $record) {
        $record->setNsdName("new.nsd.name.");
    }

    // or they can be deleted
    foreach ($zone->iterateMx() as $record) {
        $record->remove();
    }

    // zone can be validate
    if(! $zone->validate()) {
        // and if any errors, you can see them as array
        $zone->getErrorsStore()->toArray();
        // or can iterate via all, and remove invalid records for example
        foreach ($zone->getErrorsStore()->iterate() as $error) {
            if($error->isHasRecord()) {
                $error->getRecord()->remove();
            }
        }
    }

    // You can print zone as string, to put in in real zone file
    $content = (string) $zone;
    file_put_contents(__DIR__."/dns/zones/zone.conf", $content);

    // Or you can store it in array format
    $array_content = $zone->toArray();

    // and make zone again from array format
    Zone::fromArray("voksiv.ru.", $array_content);

    // also you can make zone programmatically
    $zone = new Zone("voksiv.ru.");
    $node = $zone->getNode("@");
    $node->getRecordAppender()->appendARecord("127.0.0.1");
    $node->getRecordAppender()->appendNsRecord("google.com.");

Dns zone file tokenize only

if you want only tokenize zone file you can use this library, (*3)

Developers

Regenerate documentation

$ ./vendor/bin/phpdox

Run tests

$ php phpunit.phar --coverage-html coverage

License

dns-zone-configurator is released under the MIT License. See the bundled LICENSE file for details., (*4)

The Versions

15/08 2017

dev-master

9999999-dev

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

15/08 2017

v1.1.9

1.1.9.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

18/05 2017

1.1.8

1.1.8.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

18/07 2016

1.1.7

1.1.7.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

05/07 2016

1.1.6

1.1.6.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

04/07 2016

1.1.5

1.1.5.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

01/07 2016

1.1.4

1.1.4.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

03/06 2016

v1.1.3

1.1.3.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

26/05 2016

1.1.2

1.1.2.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

25/05 2016

1.1.1

1.1.1.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

13/05 2016

v1.1.0

1.1.0.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

06/05 2016

v1.0.9

1.0.9.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

06/05 2016

v1.0.8

1.0.8.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

14/04 2016

1.0.5

1.0.5.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

14/04 2016

v1.0.6

1.0.6.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

14/04 2016

v1.0.7

1.0.7.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

13/04 2016

1.0.4

1.0.4.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

12/04 2016

1.0.3

1.0.3.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

12/04 2016

1.0.2

1.0.2.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

12/04 2016

1.0.1

1.0.1.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file

12/04 2016

1.0.0

1.0.0.0

Php library for parsing and editing dns zones files programmatically with high level abstraction.

  Sources   Download

MIT

The Requires

 

The Development Requires

dns zone file