PHPackages                             badcow/dns-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. badcow/dns-parser

Abandoned → [badcow/dns](/?search=badcow%2Fdns)ArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

badcow/dns-parser
=================

A PHP library for parsing DNS zone files based on RFC1035

v1.7.1(7y ago)176502PHPPHP ~7.1

Since Nov 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Badcow/DNS-Parser)[ Packagist](https://packagist.org/packages/badcow/dns-parser)[ RSS](/packages/badcow-dns-parser/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (15)Used By (0)

!! Code-base has been moved !!
==============================

[](#-code-base-has-been-moved-)

The DNS Parser has been incorporated into [Badcow DNS Zone Library](https://github.com/Badcow/DNS) to enable a better release cycle. The namespaces remain unchanged. You only need to include `badcow/dns` in your composer config.

Badcow DNS Zone Parser
======================

[](#badcow-dns-zone-parser)

This library parses DNS zone files and outputs DNS objects (see [Badcow DNS Zone Library](https://github.com/Badcow/DNS))

Build Status
------------

[](#build-status)

[![Build Status](https://camo.githubusercontent.com/5609e7e796a0ea343643fb2dc5486ac133984362fcbce303b4eb3f5b7a68545c/68747470733a2f2f7472617669732d63692e6f72672f426164636f772f444e532d5061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Badcow/DNS-Parser)[![Code Coverage](https://camo.githubusercontent.com/beb7ff0a16e070e59777764274f12ca8a74e3ed84d5a5f76b2eb2c96f615a9e3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426164636f772f444e532d5061727365722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Badcow/DNS-Parser/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d83bd7d3466fe16606a601e995edb2b31c930216d178c39cb7e11a7dc33f92e9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426164636f772f444e532d5061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Badcow/DNS-Parser/?branch=master)

Usage
-----

[](#usage)

```
$file = file_get_contents('/path/to/example.com.txt');

$zone = Badcow\DNS\Parser\Parser::parse('example.com.', $file);
```

Simple as that.

Installation
------------

[](#installation)

Using composer...

```
"require": {
        "badcow/dns-parser": "~1.0"
    }
```

Example
-------

[](#example)

### BIND Record

[](#bind-record)

```
$ORIGIN example.com.
$TTL 3600
@            IN SOA  (
                     example.com.       ; MNAME
                     post.example.com.  ; RNAME
                     2014110501         ; SERIAL
                     3600               ; REFRESH
                     14400              ; RETRY
                     604800             ; EXPIRE
                     3600               ; MINIMUM
                     )

 ; NS RECORDS
@               NS   ns1.nameserver.com.
@               NS   ns2.nameserver.com.

info            TXT "This is some additional \"information\""

 ; A RECORDS
sub.domain      A    192.168.1.42 ; This is a local ip.

 ; AAAA RECORDS
ipv6.domain    AAAA ::1 ; This is an IPv6 domain.

 ; MX RECORDS
@               MX   10 mail-gw1.example.net.
@               MX   20 mail-gw2.example.net.
@               MX   30 mail-gw3.example.net.

mail     IN     TXT  "THIS IS SOME TEXT; WITH A SEMICOLON"

```

### Processing the record

[](#processing-the-record)

```
