{"id":13518372,"url":"https://github.com/Badcow/DNS","last_synced_at":"2025-03-31T09:31:29.412Z","repository":{"id":29964429,"uuid":"33511277","full_name":"Badcow/DNS","owner":"Badcow","description":"The aim of this project is to create abstract object representations of DNS records in PHP. The project consists of various classes representing DNS objects (such as Zone, ResourceRecord, and various RData types), a parser to convert BIND style text files to the PHP objects, and builders to create aesthetically pleasing BIND records.","archived":false,"fork":false,"pushed_at":"2024-08-06T13:52:14.000Z","size":908,"stargazers_count":262,"open_issues_count":7,"forks_count":41,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-05T09:17:34.068Z","etag":null,"topics":["bind","dns","named","php","web"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Badcow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-4.x.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"docs/Supported-Types.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-06T23:31:36.000Z","updated_at":"2025-02-05T15:56:20.000Z","dependencies_parsed_at":"2024-11-01T23:31:56.795Z","dependency_job_id":"a2a94860-7577-4a1a-a9fd-35be56fbe1bf","html_url":"https://github.com/Badcow/DNS","commit_stats":{"total_commits":416,"total_committers":15,"mean_commits":"27.733333333333334","dds":0.09855769230769229,"last_synced_commit":"18557bc22fc4cd50a56cab4063df1d1d9748e8e0"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badcow%2FDNS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badcow%2FDNS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badcow%2FDNS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badcow%2FDNS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Badcow","download_url":"https://codeload.github.com/Badcow/DNS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246446927,"owners_count":20778893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bind","dns","named","php","web"],"created_at":"2024-08-01T05:01:44.079Z","updated_at":"2025-03-31T09:31:28.929Z","avatar_url":"https://github.com/Badcow.png","language":"PHP","readme":"Badcow DNS Library\n==================\nThe aim of this project is to create abstract object representations of DNS records in PHP. The project consists of various\nclasses representing DNS objects (such as `Zone`, `ResourceRecord`, and various `RData` types), a parser to convert BIND\nstyle text files to the PHP objects, and builders to create aesthetically pleasing BIND records.\n\nThe library can parse and encode DNS messages enabling developers to create DNS client/server platforms in pure PHP.\n\n## Build Status\n[![Build Status: PHP 8](https://github.com/Badcow/DNS/workflows/PHP%208/badge.svg)](https://github.com/Badcow/DNS/actions?query=workflow%3A%22PHP+8%22)\n\n## Contents\n1. [Example usage](#example-usage)\n2. [Example Output](#output)\n3. [Supported Types](#supported-types)\n4. [Parsing BIND Records](#parsing-bind-records)\n\n## Example usage\n\n```php\nrequire_once '/path/to/vendor/autoload.php';\n\nuse Badcow\\DNS\\Classes;\nuse Badcow\\DNS\\Zone;\nuse Badcow\\DNS\\Rdata\\Factory;\nuse Badcow\\DNS\\ResourceRecord;\nuse Badcow\\DNS\\AlignedBuilder;\n\n$zone = new Zone('example.com.');\n$zone-\u003esetDefaultTtl(3600);\n\n$soa = new ResourceRecord;\n$soa-\u003esetName('@');\n$soa-\u003esetClass(Classes::INTERNET);\n$soa-\u003esetRdata(Factory::Soa(\n    'example.com.',\n    'post.example.com.',\n    '2014110501',\n    3600,\n    14400,\n    604800,\n    3600\n));\n\n$ns1 = new ResourceRecord;\n$ns1-\u003esetName('@');\n$ns1-\u003esetClass(Classes::INTERNET);\n$ns1-\u003esetRdata(Factory::Ns('ns1.nameserver.com.'));\n\n$ns2 = new ResourceRecord;\n$ns2-\u003esetName('@');\n$ns2-\u003esetClass(Classes::INTERNET);\n$ns2-\u003esetRdata(Factory::Ns('ns2.nameserver.com.'));\n\n$a = new ResourceRecord;\n$a-\u003esetName('sub.domain');\n$a-\u003esetRdata(Factory::A('192.168.1.42'));\n$a-\u003esetComment('This is a local ip.');\n\n$a6 = new ResourceRecord;\n$a6-\u003esetName('ipv6.domain');\n$a6-\u003esetRdata(Factory::Aaaa('::1'));\n$a6-\u003esetComment('This is an IPv6 domain.');\n\n$mx1 = new ResourceRecord;\n$mx1-\u003esetName('@');\n$mx1-\u003esetRdata(Factory::Mx(10, 'mail-gw1.example.net.'));\n\n$mx2 = new ResourceRecord;\n$mx2-\u003esetName('@');\n$mx2-\u003esetRdata(Factory::Mx(20, 'mail-gw2.example.net.'));\n\n$mx3 = new ResourceRecord;\n$mx3-\u003esetName('@');\n$mx3-\u003esetRdata(Factory::Mx(30, 'mail-gw3.example.net.'));\n\n$zone-\u003eaddResourceRecord($soa);\n$zone-\u003eaddResourceRecord($mx2);\n$zone-\u003eaddResourceRecord($ns1);\n$zone-\u003eaddResourceRecord($mx3);\n$zone-\u003eaddResourceRecord($a);\n$zone-\u003eaddResourceRecord($a6);\n$zone-\u003eaddResourceRecord($ns2);\n$zone-\u003eaddResourceRecord($mx1);\n\n$builder = new AlignedBuilder();\necho $builder-\u003ebuild($zone);\n```\n\n### Output\n```txt\n$ORIGIN example.com.\n$TTL 3600\n@            IN SOA  (\n                     example.com.      ; MNAME\n                     post.example.com. ; RNAME\n                     2014110501        ; SERIAL\n                     3600              ; REFRESH\n                     14400             ; RETRY\n                     604800            ; EXPIRE\n                     3600              ; MINIMUM\n                     )\n\n; NS RECORDS\n@            IN NS   ns1.nameserver.com.\n@            IN NS   ns2.nameserver.com.\n\n; A RECORDS\nsub.domain      A    192.168.1.42; This is a local ip.\n\n; AAAA RECORDS\nipv6.domain     AAAA ::1; This is an IPv6 domain.\n\n; MX RECORDS\n@               MX   10 mail-gw1.example.net.\n@               MX   20 mail-gw2.example.net.\n@               MX   30 mail-gw3.example.net.\n```\n\nThe above is an example of the `AlignedBuilder` which creates records that are much more aesthetically pleasing. You can\nalso use the flat `ZoneBuilder`, the output of which is below:\n\n```php\n...\necho ZoneBuilder::build($zone);\n```\n```txt\n$ORIGIN example.com.\n$TTL 3600\n@ IN SOA example.com. post.example.com. 2014110501 3600 14400 604800 3600\n@ MX 20 mail-gw2.example.net.\n@ IN NS ns1.nameserver.com.\n@ MX 30 mail-gw3.example.net.\nsub.domain A 192.168.1.42; This is a local ip.\nipv6.domain AAAA ::1; This is an IPv6 domain.\n@ IN NS ns2.nameserver.com.\n@ MX 10 mail-gw1.example.net.\n```\n\n## Supported Types\nAll ubiquitous DNS types are supported. For full details on supported types see [the Documentation](docs/Supported-Types.md).\n\n## Parsing BIND Records\n\nBIND Records can be parsed into PHP objects using `Badcow\\DNS\\Parser\\Parser`\n\n```php\n$file = file_get_contents('/path/to/example.com.txt');\n$zone = Badcow\\DNS\\Parser\\Parser::parse('example.com.', $file); //Badcow Zone Object\n```\n\nSimple as that.\n\nMore examples can be found in the [The Docs](docs/Parser)\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBadcow%2FDNS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBadcow%2FDNS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBadcow%2FDNS/lists"}