{"id":21328161,"url":"https://github.com/hampel/tlds","last_synced_at":"2025-03-16T00:16:37.632Z","repository":{"id":174870400,"uuid":"652362702","full_name":"hampel/tlds","owner":"hampel","description":"Fetches the latest list of Top Level Domains from IANA, plus Laravel classes for validating TLDs","archived":false,"fork":false,"pushed_at":"2024-05-08T08:01:39.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T17:51:57.758Z","etag":null,"topics":["domain-names","domainname","domains","iana","tld","top-level-domains"],"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/hampel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"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}},"created_at":"2023-06-11T22:45:07.000Z","updated_at":"2024-05-08T08:01:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"7bbf08bf-eb06-4261-96b0-21b938b7dc2c","html_url":"https://github.com/hampel/tlds","commit_stats":null,"previous_names":["hampel/tlds"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Ftlds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Ftlds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Ftlds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Ftlds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hampel","download_url":"https://codeload.github.com/hampel/tlds/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806093,"owners_count":20350775,"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":["domain-names","domainname","domains","iana","tld","top-level-domains"],"created_at":"2024-11-21T21:24:40.118Z","updated_at":"2025-03-16T00:16:37.483Z","avatar_url":"https://github.com/hampel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Top Level Domain Fetcher for Laravel\n====================================\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/hampel/tlds.svg?style=flat-square)](https://packagist.org/packages/hampel/tlds)\n[![Total Downloads](https://img.shields.io/packagist/dt/hampel/tlds.svg?style=flat-square)](https://packagist.org/packages/hampel/tlds)\n[![Open Issues](https://img.shields.io/github/issues-raw/hampel/tlds.svg?style=flat-square)](https://github.com/hampel/tlds/issues)\n[![License](https://img.shields.io/packagist/l/hampel/tlds.svg?style=flat-square)](https://packagist.org/packages/hampel/tlds)\n\nThis package provides a mechanism for retrieving a list of the current Top Level Domains (TLDs) managed by IANA.\nIt also provides several Laravel classes to validate domain names and TLDs.\n\nBy [Simon Hampel](mailto:simon@hampelgroup.com)\n\nCompatibility\n-------------\n\n- Laravel 9.x - use hampel/tlds 1.10.x\n- Laravel 10.x - use hampel/tlds 2.x\n- Laravel 11.x - use hampel/tlds 2.1.x\n\nInstallation\n------------\n\nTo install using composer, run the following command:\n\n`composer require hampel/tlds`\n\nIf you want to change the default Tlds configuration, first publish it using the command:\n\n```bash\n$ php artisan vendor:publish --provider=\"Hampel\\Tlds\\TldServiceProvider\"\n```\n\nThe config files can then be found in `config/tlds.php`.\n\nConfiguration\n-------------\n\nRefer to the configuration file  for more details about configuration options.\n\n__tlds.cache.expiry__ - sets the cache expiry time in seconds\n\n__tlds.cache.key__ - sets the key used to store the TLD data in the cache\n\n__tlds.source__ - set this to 'url' to retrieve the data from a website (eg IANA), set it to 'filesystem' to retrieve\nthe data from a local source (you'll need to configure a Laravel filesystem 'disk' to make this work).\n\n__tlds.url__ - if source is set to 'url', enter the URL to retrieve the data from. By default this is set to the\nIANA source file\n\n__tlds.disk__ - if source is set to 'filesystem', enter the name of the Laravel filesystem disk you have\nconfigured in the 'filesystems.disks' configuration option\n\n__tlds.path__ - if source is set to 'filesystem', enter the path to the data file relative to the root path\nconfigured for the disk in the 'fileystems.disks' configuration option (eg. 'tlds/tlds-alpha-by-domain.txt')\n\nUsage\n-----\n\nThe Tlds package provides a simple mechanism for reading a data file containing a list of Top Level Domains, one per\nline and returning an array of data. This data may optionally be cached for performance.\n\nThe data file can be retrieved directly from the Internet Assigned Numbers Authority (IANA) website, using Guzzle, or\nif you have a different source or prefer to fetch the data file yourself and then read it from a local source you can\nreconfigure the Tlds package to read the data file from any Laravel supported filesystem (using Flysystem).\n\nThere is also an artisan command available which can be used to fetch the latest data file to refresh the cache. This\nis ideal for automating the retrieval of data using a cron job or similar.\n\nThe simplest way to call the package is using the Facade:\n\n```php\n// get a \"fresh\" copy of the TLD list\n$tld_array = Tlds::fresh();\n\n// or if you prefer to not use Facades:\n$tld_array = $app-\u003emake(Hampel\\Tlds\\TldManager::class)-\u003efresh();\n```\n\nThis returns a \"fresh\" copy of the data (bypassing the cache) as an array of TLDs.\n\nTo fetch the TLD array from the cache or have it update automatically if the cached data has expired\n\n```php\n// get the TLD list from the cache (or update the cache if it has expired)\n$tld_array = Tlds::get();\n\n// if you prefer to manage the cache yourself, you can do this all manually, for example:\nif (Cache::has(Config::get('tlds.cache.key'))\n{\n    $tld_array = Cache::get(Config::get('tlds.cache.key'));\n}\nelse\n{\n    Cache::put(Config::get('tlds.cache.key'), Tlds::fresh(), Config::get('tlds.cache.expiry'));\n}\n```\n\nTo run the artisan console command to update the cache:\n\n```bash\n$ php artisan tld:update\nAdded 725 TLDs to the TLD Cache\n```\n\nValidators\n----------\n\nThis package adds additional validators for Laravel v10.x and above - refer to\n[Laravel Documentation - Validation](http://laravel.com/docs/validation) for general usage instructions.\n\n__Domain__\n\nThe field under validation must be a valid domain name. The Top Level Domain (TLD) is checked against a list of all\nacceptable TLDs, including internationalised domains in punycode notation\n\nExample:\n\n```php\nuse Hampel\\Tlds\\Validation\\Domain;\n\n// valid values: example.com; example.au\n// invalid values: example.invalid-tld\n\n$request-\u003evalidate([\n    'domain' =\u003e ['required', 'string', new Domain],\n]);\n```\n\n**DomainIn([\u0026lt;array of TLDs\u0026gt;])**\n\nThe field under validation must be a valid domain with a TLD from one of the specified options\n\nExample:\n\n```php\nuse Hampel\\Tlds\\Validation\\DomainIn;\n\n// valid values: example.com; example.net\n// invalid values: example.co; example.au (not in specified list of domain TLDs)\n\n$request-\u003evalidate([\n    'domain' =\u003e ['required', 'string', new DomainIn(['com', 'net')],\n]);\n```\n\n__Tld__\n\nThe field under validation must end in a valid Top Level Domain (TLD). The TLD is checked against a list of all\nacceptable TLDs, including internationalised domains in punycode notation\n\nIf no dots are contained in the supplied value, it will be assumed to be only a TLD.\n\nIf the value contains dots, only the part after the last dot will be validated.\n\nExample:\n\n```php\nuse Hampel\\Tlds\\Validation\\Tld;\n\n// valid values: example.com; com; net (either a domain with a valid TLD, or a string that is itself a valid TLD)\n// invalid values: example.invalid-tld; something-not-a-tld\n\n$request-\u003evalidate([\n    'domain' =\u003e ['required', 'string', new Tld],\n]);\n```\n\n**TldIn([\u0026lt;array of TLDs\u0026gt;])**\n\nThe field under validation must end in a TLD from one of the specified options\n\nIf no dots are contained in the supplied value, it will be assumed to be only a TLD.\n\nIf the value contains dots, only the part after the last dot will be validated.\n\nExample:\n\n```php\nuse Hampel\\Tlds\\Validation\\TldIn;\n\n// valid values: example.com; example.net; com; net\n// invalid values: example.co; org (not in specified list of domain TLDs)\n\n$request-\u003evalidate([\n    'domain' =\u003e ['required', 'string', new TldIn(['com', 'net'])],\n]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhampel%2Ftlds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhampel%2Ftlds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhampel%2Ftlds/lists"}