Download the PHP package hampel/tlds without Composer

On this page you can find all versions of the php package hampel/tlds. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tlds

Top Level Domain Fetcher for Laravel

Tests Latest Version on Packagist Total Downloads Open Issues License

This package provides a mechanism for retrieving a list of the current Top Level Domains (TLDs) managed by IANA. It also provides several Laravel classes to validate domain names and TLDs.

By Simon Hampel

Compatibility

Requires PHP 8.3 or later.

Installation

To install using composer, run the following command:

composer require hampel/tlds

If you want to change the default Tlds configuration, first publish it using the command:

The config file can then be found in config/tlds.php.

Configuration

tlds.url - the URL to retrieve the data from. By default this is set to the IANA source file

tlds.cache.expiry - sets the cache expiry time in seconds

tlds.cache.key - sets the key used to store the TLD data in the cache

tlds.cache.store - which of your application's configured cache stores to keep the data in. Set to null to use the default store

Usage

The Tlds package reads a data file containing a list of Top Level Domains, one per line, and returns an array of data. This data may optionally be cached for performance.

The data file is retrieved from the Internet Assigned Numbers Authority (IANA) website over HTTP.

The simplest way to call the package is using the Facade:

This returns a "fresh" copy of the data (bypassing the cache) as an array of TLDs.

To fetch the TLD array from the cache or have it update automatically if the cached data has expired

To run the artisan console command to update the cache:

This is ideal for automating the retrieval of data using a cron job or similar.

Any line in the source data that is not a valid TLD is skipped, and reported by the console command:

Reading the TLD list from somewhere else

To read the list from a local file, an internal mirror, or any other source, implement Hampel\Tlds\Fetcher\TldFetcher and bind it in your application's service provider. The tlds.url setting is then unused.

The interface has a single method, which returns the raw file contents as a string:

The source data format is assumed to be:

Validators

This package adds additional validators for Laravel - refer to Laravel Documentation - Validation for general usage instructions.

Domain

The field under validation must be a valid domain name. The Top Level Domain (TLD) is checked against a list of all acceptable TLDs, including internationalised domains in punycode notation

Example:

DomainIn([<array of TLDs>])

The field under validation must be a valid domain with a TLD from one of the specified options

Example:

Tld

The field under validation must end in a valid Top Level Domain (TLD). The TLD is checked against a list of all acceptable TLDs, including internationalised domains in punycode notation

If no dots are contained in the supplied value, it will be assumed to be only a TLD.

If the value contains dots, only the part after the last dot will be validated.

Example:

TldIn([<array of TLDs>])

The field under validation must end in a TLD from one of the specified options

If no dots are contained in the supplied value, it will be assumed to be only a TLD.

If the value contains dots, only the part after the last dot will be validated.

Example:


All versions of tlds with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
hampel/validate Version ~2.2
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hampel/tlds contains the following files

Loading the files please wait ...