{"id":15916874,"url":"https://github.com/utopia-php/domains","last_synced_at":"2026-03-02T13:14:36.113Z","repository":{"id":40486920,"uuid":"242066561","full_name":"utopia-php/domains","owner":"utopia-php","description":"Lite \u0026 fast micro PHP domain parsing library that is **easy to use**.","archived":false,"fork":false,"pushed_at":"2026-01-12T12:50:55.000Z","size":2326,"stargazers_count":51,"open_issues_count":8,"forks_count":21,"subscribers_count":11,"default_branch":"master","last_synced_at":"2026-01-12T15:24:10.479Z","etag":null,"topics":["hacktoberfest","php"],"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/utopia-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-02-21T06:03:09.000Z","updated_at":"2025-12-28T15:06:32.000Z","dependencies_parsed_at":"2024-04-08T04:26:12.199Z","dependency_job_id":"cec3c576-7980-4f5f-b2d8-cc4e5b43898e","html_url":"https://github.com/utopia-php/domains","commit_stats":{"total_commits":149,"total_committers":19,"mean_commits":7.842105263157895,"dds":0.7583892617449665,"last_synced_commit":"5c70b0f524deeb1fccc3962ad1da650ae2c94cda"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/utopia-php/domains","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fdomains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fdomains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fdomains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fdomains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/domains/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fdomains/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28692002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T11:01:27.039Z","status":"ssl_error","status_checked_at":"2026-01-23T11:00:26.909Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hacktoberfest","php"],"created_at":"2024-10-06T18:06:08.135Z","updated_at":"2026-03-02T13:14:36.105Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utopia Domains\n\n[![Build Status](https://travis-ci.org/utopia-php/domains.svg?branch=master)](https://travis-ci.com/utopia-php/domains)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/domains.svg)\n[![Discord](https://img.shields.io/discord/564160730845151244)](https://appwrite.io/discord)\n\nUtopia Domains library is a simple and lite library for parsing domain names structure. This library is aiming to be as simple and easy to learn and use.  This library is maintained by the [Appwrite team](https://appwrite.io).\n\nAlthough this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project, it is completely **dependency-free** and can be used as standalone with any other PHP project or framework.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/domains\n```\n\n```php\n\u003c?php\n\nrequire_once '../vendor/autoload.php';\n\nuse Utopia\\Domains\\Domain;\n\n// demo.example.co.uk\n\n$domain = new Domain('demo.example.co.uk');\n\n$domain-\u003eget(); // demo.example.co.uk\n$domain-\u003egetTLD(); // uk\n$domain-\u003egetSuffix(); // co.uk\n$domain-\u003egetRegisterable(); // example.co.uk\n$domain-\u003egetName(); // example\n$domain-\u003egetSub(); // demo\n$domain-\u003eisKnown(); // true\n$domain-\u003eisICANN(); // true\n$domain-\u003eisPrivate(); // false\n$domain-\u003eisTest(); // false\n\n// demo.localhost\n\n$domain = new Domain('demo.localhost');\n\n$domain-\u003eget(); // demo.localhost\n$domain-\u003egetTLD(); // localhost\n$domain-\u003egetSuffix(); // ''\n$domain-\u003egetRegisterable(); // ''\n$domain-\u003egetName(); // demo\n$domain-\u003egetSub(); // ''\n$domain-\u003eisKnown(); // false\n$domain-\u003eisICANN(); // false\n$domain-\u003eisPrivate(); // false\n$domain-\u003eisTest(); // true\n\n```\n\nUtopia Domains parser uses a public suffix PHP dataset auto-generated from the [publicsuffix.org](https://publicsuffix.org/). The dataset get periodically updates from us, but you can also manually update it by cloning this library and running the import script with the import command:\n\n```bash\nphp ./data/import.php\n```\n\n## Library API\n\n* **get()** - Return you full domain name.\n* **getTLD()** - Return only the top-level-domain.\n* **getSuffix()** - Return only the public suffix of your domain, for example: co.uk, ac.be, org.il, com, org.\n* **getRegisterable()** - Return the registered or registrable domain, which is the public suffix plus one additional label.\n* **getName()** - Returns only the registerable domain name. For example, blog.example.com will return 'example', and demo.co.uk will return 'demo'.\n* **getSub()** - Returns the full sub domain path for you domain. For example, blog.example.com will return 'blog', and subdomain.demo.co.uk will return 'subdomain.demo'.\n* **isKnown()** - Returns true if public suffix is know and false otherwise.\n* **isICANN()** - Returns true if the public suffix is found in the ICANN DOMAINS section of the public suffix list.\n* **isPrivate()** - Returns true if the public suffix is found in the PRIVATE DOMAINS section of the public suffix list.\n* **isTest()** - Returns true if the domain TLD is 'locahost' or 'test' and false otherwise.\n\n\u003e If you want to parse ordinary web urls then use `$host = parse_url($return, PHP_URL_HOST); $domain = new Utopia\\Domains\\Domain($host);` to get the domain object. \n\n\n## Using the Registrar API\n\nThe library supports multiple domain registrar adapters:\n- **OpenSRS** - OpenSRS domain registrar\n- **NameCom** - Name.com domain registrar\n\n### Using OpenSRS Adapter\n```php\n\u003c?php\n\nuse Utopia\\Domains\\Registrar;\nuse Utopia\\Domains\\Registrar\\Contact;\nuse Utopia\\Domains\\Registrar\\Adapter\\OpenSRS;\n\n$opensrs = new OpenSRS(\n  'apikey',\n  'username',\n  'password',\n  [\n    'ns1.nameserver.com',\n    'ns2.nameserver.com',\n  ],\n  'https://horizon.opensrs.net:55443' // or 'https://rr-n1-tor.opensrs.net:55443' for production\n);\n\n$reg = new Registrar($opensrs);\n```\n\n### Using NameCom Adapter\n```php\n\u003c?php\n\nuse Utopia\\Domains\\Registrar;\nuse Utopia\\Domains\\Registrar\\Contact;\nuse Utopia\\Domains\\Registrar\\Adapter\\NameCom;\n\n$namecom = new NameCom(\n  'username',\n  'api-token',\n  [\n    'ns1.name.com',\n    'ns2.name.com',\n  ],\n  'https://api.name.com' // or 'https://api.dev.name.com' for testing\n);\n\n$reg = new Registrar($namecom);\n```\n\n### Using the Registrar\nOnce you have initialized an adapter, you can use the Registrar API:\n\n```php\n$reg = new Registrar($adapter); // $adapter can be OpenSRS or NameCom\n\n$contact = new Contact(\n  'firstname',\n  'lastname',\n  'phone',\n  'email',\n  'address1',\n  'address2',\n  'address3',\n  'city',\n  'state',\n  'country',\n  'postalcode',\n  'org',\n  'owner',\n);\n\n$domain = 'yourname.com';\n\n$available = $reg-\u003eavailable($domain);\n$purchase = $reg-\u003epurchase($domain, [$contact]);\n$purchase = $reg-\u003epurchase($domain, [$contact], 1);\n$suggest = $reg-\u003esuggest(['yourname', 'yourname1.com'], ['com', 'net', 'org'], 10, 10000, 100);\n$domainDetails = $reg-\u003egetDomain($domain);\n$renew = $reg-\u003erenew($domain, 1);\n$transfer = $reg-\u003etransfer($domain, [$contact]);\n$transfer = $reg-\u003etransfer($domain, 'authcode', [$contact]);\n\n```\n\n### Update Auto-Renew\n```php\nuse Utopia\\Domains\\Registrar\\UpdateDetails;\n\n$details = new UpdateDetails(autoRenew: true);\n$reg-\u003eupdateDomain($domain, $details);\n```\n\n## Library Registrar API\n* **available(string $domain): bool** - Checks to see if a domain is available for registration.\n* **purchase(string $domain, array|Contact $contacts, int $periodYears = 1, array $nameservers = []): Registration** - Purchase a domain name and returns a Registration object.\n* **suggest(array $query, array $tlds = [], int|null $limit = null, int|null $priceMax = null, int|null $priceMin = null): array** - Suggest or search for domain names.\n* **getDomain(string $domain): Domain** - Get domain details and returns a Domain object.\n* **updateDomain(string $domain, UpdateDetails $details): bool** - Update domain details such as auto-renew.\n* **renew(string $domain, int $periodYears): Renewal** - Renewal a domain name and returns a Renewal object.\n* **transfer(string $domain, string $authCode, array|Contact $contacts, int $periodYears = 1, array $nameservers = []): Registration** - Transfer a domain name and returns a Registration object.\n* **getAuthCode(string $domain): string** - Retrieve the authorization code for a domain.\n* **checkTransferStatus(string $domain, bool $checkStatus = true, bool $getRequestAddress = false): TransferStatus** - Check the transfer status of a domain.\n\n\n## System Requirements\n\nUtopia Framework requires PHP 8.2 or later. We recommend using the latest PHP version whenever possible.\n\n## Authors\n\n**Eldad Fux**\n\n+ [https://twitter.com/eldadfux](https://twitter.com/eldadfux)\n+ [https://github.com/eldadfux](https://github.com/eldadfux)\n\n## Copyright and license\n\nThe MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fdomains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Fdomains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fdomains/lists"}