arubacao / tld-checker
Top Level Domain (TLD) validation library for PHP
Requires
- php: ^8.1
- ext-intl: *
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^9.5|^10.5|^11.5|^12.5
Suggests
- illuminate/validation: Required for Laravel validation
- dev-master
- 2.0.2
- 2.0.1
- 2.0.0
- 1.3.0
- 1.2.292
- 1.2.291
- 1.2.290
- 1.2.289
- 1.2.288
- 1.2.287
- 1.2.286
- 1.2.285
- 1.2.284
- 1.2.283
- 1.2.282
- 1.2.281
- 1.2.280
- 1.2.279
- 1.2.278
- 1.2.277
- 1.2.276
- 1.2.275
- 1.2.274
- 1.2.273
- 1.2.272
- 1.2.271
- 1.2.270
- 1.2.269
- 1.2.268
- 1.2.267
- 1.2.266
- 1.2.265
- 1.2.264
- 1.2.263
- 1.2.262
- 1.2.261
- 1.2.260
- 1.2.259
- 1.2.258
- 1.2.257
- 1.2.256
- 1.2.255
- 1.2.254
- 1.2.253
- 1.2.252
- 1.2.251
- 1.2.250
- 1.2.249
- 1.2.248
- 1.2.247
- 1.2.246
- 1.2.245
- 1.2.244
- 1.2.243
- 1.2.242
- 1.2.241
- 1.2.240
- 1.2.239
- 1.2.238
- 1.2.237
- 1.2.236
- 1.2.235
- 1.2.234
- 1.2.233
- 1.2.232
- 1.2.231
- 1.2.230
- 1.2.229
- 1.2.228
- 1.2.227
- 1.2.226
- 1.2.225
- 1.2.224
- 1.2.223
- 1.2.222
- 1.2.221
- 1.2.220
- 1.2.219
- 1.2.218
- 1.2.217
- 1.2.216
- 1.2.215
- 1.2.214
- 1.2.213
- 1.2.212
- 1.2.211
- 1.2.210
- 1.2.209
- 1.2.208
- 1.2.207
- 1.2.206
- 1.2.205
- 1.2.204
- 1.2.203
- 1.2.202
- 1.2.201
- 1.2.200
- 1.2.199
- 1.2.198
- 1.2.197
- 1.2.196
- 1.2.195
- 1.2.194
- 1.2.193
- 1.2.192
- 1.2.191
- 1.2.190
- 1.2.189
- 1.2.188
- 1.2.187
- 1.2.186
- 1.2.185
- 1.2.184
- 1.2.183
- 1.2.182
- 1.2.181
- 1.2.180
- 1.2.179
- 1.2.178
- 1.2.177
- 1.2.176
- 1.2.175
- 1.2.174
- 1.2.173
- 1.2.172
- 1.2.171
- 1.2.170
- 1.2.169
- 1.2.168
- 1.2.167
- 1.2.166
- 1.2.165
- 1.2.164
- 1.2.163
- 1.2.162
- 1.2.161
- 1.2.160
- 1.2.159
- 1.2.158
- 1.2.157
- 1.2.156
- 1.2.155
- 1.2.154
- 1.2.153
- 1.2.152
- 1.2.151
- 1.2.150
- 1.2.149
- 1.2.148
- 1.2.147
- 1.2.146
- 1.2.145
- 1.2.144
- 1.2.143
- 1.2.142
- 1.2.141
- 1.2.140
- 1.2.139
- 1.2.138
- 1.2.137
- 1.2.136
- 1.2.135
- 1.2.134
- 1.2.133
- 1.2.132
- 1.2.131
- 1.2.130
- 1.2.129
- 1.2.128
- 1.2.127
- 1.2.126
- 1.2.125
- 1.2.124
- 1.2.123
- 1.2.122
- 1.2.121
- 1.2.120
- 1.2.119
- 1.2.118
- 1.2.117
- 1.2.116
- 1.2.115
- 1.2.114
- 1.2.113
- 1.2.112
- 1.2.111
- 1.2.110
- 1.2.109
- 1.2.108
- 1.2.107
- 1.2.106
- 1.2.105
- 1.2.104
- 1.2.103
- 1.2.102
- 1.2.101
- 1.2.100
- 1.2.99
- 1.2.98
- 1.2.97
- 1.2.96
- 1.2.95
- 1.2.94
- 1.2.93
- 1.2.92
- 1.2.91
- 1.2.90
- 1.2.89
- 1.2.88
- 1.2.87
- 1.2.86
- 1.2.85
- 1.2.84
- 1.2.83
- 1.2.82
- 1.2.81
- 1.2.80
- 1.2.79
- 1.2.78
- 1.2.77
- 1.2.76
- 1.2.75
- 1.2.74
- 1.2.73
- 1.2.72
- 1.2.71
- 1.2.70
- 1.2.69
- 1.2.68
- 1.2.67
- 1.2.66
- 1.2.65
- 1.2.64
- 1.2.63
- 1.2.62
- 1.2.61
- 1.2.60
- 1.2.59
- 1.2.58
- 1.2.57
- 1.2.56
- 1.2.55
- 1.2.54
- 1.2.53
- 1.2.52
- 1.2.51
- 1.2.50
- 1.2.49
- 1.2.48
- 1.2.47
- 1.2.46
- 1.2.45
- 1.2.44
- 1.2.43
- 1.2.42
- 1.2.41
- 1.2.40
- 1.2.39
- 1.2.38
- 1.2.37
- 1.2.36
- 1.2.35
- 1.2.34
- 1.2.33
- 1.2.32
- 1.2.31
- 1.2.30
- 1.2.29
- 1.2.28
- 1.2.27
- 1.2.26
- 1.2.25
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.50
- 1.1.49
- 1.1.48
- 1.1.47
- 1.1.46
- 1.1.45
- 1.1.44
- 1.1.43
- 1.1.42
- 1.1.41
- 1.1.40
- 1.1.39
- 1.1.38
- 1.1.37
- 1.1.36
- 1.1.35
- 1.1.34
- 1.1.33
- 1.1.32
- 1.1.31
- 1.1.30
- 1.1.29
- 1.1.28
- 1.1.27
- 1.1.26
- 1.1.25
- 1.1.24
- 1.1.23
- 1.1.22
- 1.1.21
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0
This package is auto-updated.
Last update: 2026-05-31 07:50:34 UTC
README
This package allows validation of top level domains against the official The DNS Root Zone database from iana.org.
Use this to validate e.g. domains or email addresses.
The DNS Root Zone is the upper-most part of the DNS hierarchy, and involves delegating administrative responsibility of “top-level domains”, which are the last segment of a domain name, such as .com, .uk and .nz.
The database is stored locally and automatically updated for new database versions.
Installation
Install this package via composer:
composer require arubacao/tld-checker
Laravel
Laravel auto-discovery registers the service provider for supported Laravel versions. If auto-discovery is disabled in your application, register the provider manually:
// config/app.php 'providers' => [ // Other Service Providers Arubacao\TldChecker\TldCheckerServiceProvider::class, ],
Notes:
arubacao/tld-checkeris tested with GitHub Actions for PHP8.1-8.5& Laravel9.x-13.x.
Usage
Check a TLD using Validator::isTld():
use Arubacao\TldChecker\Validator; Validator::isTld('com'); // true Validator::isTld('CN'); // true (case insensitiv) Validator::isTld('москва'); // true (works with internationalized domain name (IDN) | unicode) Validator::isTld('XN--CZRS0T'); // true (works with encoded IDN | 商店) Validator::isTld('.org'); // true (allows dot prefix) Validator::isTld('apricot'); // false
Check if a string ends with a valid TLD using Validator::endsWithTld():
use Arubacao\TldChecker\Validator; Validator::endsWithTld('apple.com'); // true Validator::endsWithTld('NEWS.CN'); // true (case insensitiv) Validator::endsWithTld('müller.vermögensberater'); // true (works with internationalized domain name (IDN) | unicode) Validator::endsWithTld('xn--mller-kva.xn--vermgensberater-ctb');// true (works with encoded IDN | müller.vermögensberater) Validator::endsWithTld('farming.apricot'); // false
This package extends the Laravel Validator with these 2 methods:
is_tldends_with_tld
Use them as follows:
$request->validate([ 'tld' => 'required|is_tld', 'email' => 'required|ends_with_tld' ]);
Testing
composer test
Maintenance
Refresh the generated IANA database locally:
composer build
The repository also has a scheduled GitHub Actions workflow that runs every Sunday at 04:01 UTC. If IANA has published a new root zone version, the workflow commits the refreshed src/RootZoneDatabase.php file and tags the next patch release so Packagist can pick it up.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.