@@ -22,7 +22,7 @@ You can't regex that.
22
22
PHP Domain Parser is compliant around:
23
23
24
24
- accurate Public Suffix List based parsing.
25
- - accurate Root Zone Database parsing.
25
+ - accurate IANA Top Level Domain List parsing.
26
26
27
27
## Installation
28
28
@@ -48,7 +48,7 @@ You need:
48
48
This library can resolve a domain against:
49
49
50
50
- The [ Public Suffix List] ( https://publicsuffix.org/ )
51
- - The [ IANA Root Zone Database ] ( https://www.iana.org/domains/root/files )
51
+ - The [ IANA Top Level Domain List ] ( https://www.iana.org/domains/root/files )
52
52
53
53
In both cases this is done using the ` resolve ` method implemented on the resource
54
54
instance. The method returns a ` Pdp\ResolvedDomain ` object which represents the
@@ -72,15 +72,15 @@ echo $result->suffix()->toString(); //display 'okinawa.jp';
72
72
$result->suffix()->isICANN(); //return true;
73
73
~~~
74
74
75
- For the [ IANA Root Zone Database ] ( https://www.iana.org/domains/root/files ) ,
75
+ For the [ IANA Top Level Domain List ] ( https://www.iana.org/domains/root/files ) ,
76
76
the ` Pdp\TopLevelDomains ` class is use instead:
77
77
78
78
~~~ php
79
79
use Pdp\TopLevelDomains;
80
80
81
- $rootZoneDatabase = TopLevelDomains::fromPath('/path/to/cache/tlds-alpha-by-domain.txt');
81
+ $topLevelDomains = TopLevelDomains::fromPath('/path/to/cache/tlds-alpha-by-domain.txt');
82
82
83
- $result = $rootZoneDatabase ->resolve('www.PreF.OkiNawA.jP');
83
+ $result = $topLevelDomains ->resolve('www.PreF.OkiNawA.jP');
84
84
echo $result->domain()->toString(); //display 'www.pref.okinawa.jp';
85
85
echo $result->suffix()->toString(); //display 'jp';
86
86
echo $result->secondLevelDomain()->toString(); //display 'okinawa';
@@ -100,8 +100,8 @@ namely:
100
100
- ` Rules::getICANNDomain `
101
101
- ` Rules::getPrivateDomain `
102
102
103
- for the Public Suffix List and the following method for the Root Zone
104
- Database :
103
+ for the Public Suffix List and the following method for the Top Level
104
+ Domain List :
105
105
106
106
- ` TopLevelDomains::getIANADomain `
107
107
@@ -132,8 +132,8 @@ $result->suffix()->value(); // returns null
132
132
$result->suffix()->isKnown(); // returns false
133
133
// will not throw but its public suffix value equal to NULL
134
134
135
- $rootZoneDatabase = TopLevelDomains::fromPath('/path/to/cache/public-suffix-list.dat');
136
- $rootZoneDatabase ->getIANADomain('com');
135
+ $topLevelDomains = TopLevelDomains::fromPath('/path/to/cache/public-suffix-list.dat');
136
+ $topLevelDomains ->getIANADomain('com');
137
137
// will not throw because the domain syntax is invalid (ie: does not support public suffix)
138
138
~~~
139
139
@@ -150,16 +150,16 @@ resolver exposes the `JsonSerialize` method.
150
150
151
151
** WARNING:**
152
152
153
- ** You should never use resolve domain name this way in production, without, at
153
+ ** You should never resolve domain name this way in production, without, at
154
154
least, a caching mechanism to reduce PSL downloads.**
155
155
156
156
** Using the Public Suffix List to determine what is a valid domain name and what
157
157
isn't is dangerous, particularly in these days when new gTLDs are arriving at a
158
158
rapid pace.**
159
159
160
160
** If you are looking to know the validity of a Top Level Domain, the
161
- IANA Root Zone Database is the proper source for this information or alternatively
162
- consider using directly the DNS.**
161
+ IANA Top Level Domain List is the proper source for this information or
162
+ alternatively consider using directly the DNS.**
163
163
164
164
** If you must use this library for any of the above purposes, please consider
165
165
integrating an updating mechanism into your software.**
@@ -172,13 +172,13 @@ Whichever methods chosen to resolve the domain on success, the package will
172
172
return a ` Pdp\ResolvedDomain ` instance.
173
173
174
174
The ` Pdp\ResolvedDomain ` decorates the ` Pdp\Domain ` class resolved but also
175
- gives access as separate methods to the domain different components.
175
+ gives access as separate methods to the domain different components.
176
176
177
177
~~~ php
178
- use Pdp\RootZoneDatabase ;
178
+ use Pdp\TopLevelDomains ;
179
179
180
- /** @var RootZoneDatabase $rootZoneDatabase */
181
- $result = $rootZoneDatabase ->resolve('www.PreF.OkiNawA.jP');
180
+ /** @var TopLevelDomains $topLevelDomains */
181
+ $result = $topLevelDomains ->resolve('www.PreF.OkiNawA.jP');
182
182
echo $result->domain()->toString(); //display 'www.pref.okinawa.jp';
183
183
echo $result->suffix()->toString(); //display 'jp';
184
184
echo $result->secondLevelDomain()->toString(); //display 'okinawa';
@@ -192,9 +192,9 @@ You can modify the returned `Pdp\ResolvedDomain` instance using the following me
192
192
~~~ php
193
193
<?php
194
194
195
- use Pdp\PublicSuffixList ;
195
+ use Pdp\Rules ;
196
196
197
- /** @var PublicSuffixList $publicSuffixList */
197
+ /** @var Rules $publicSuffixList */
198
198
$result = $publicSuffixList->resolve('shop.example.com');
199
199
$altResult = $result
200
200
->withSubDomain('foo.bar')
@@ -221,9 +221,9 @@ origin.
221
221
222
222
~~~ php
223
223
<?php
224
- use Pdp\PublicSuffixList ;
224
+ use Pdp\Rules ;
225
225
226
- /** @var PublicSuffixList $publicSuffixList */
226
+ /** @var Rules $publicSuffixList */
227
227
$suffix = $publicSuffixList->resolve('example.github.io')->suffix();
228
228
229
229
echo $suffix->domain()->toString(); //display 'github.io';
@@ -237,7 +237,7 @@ $suffix->isKnown(); //will return true
237
237
The public suffix state depends on its origin:
238
238
239
239
- ` isKnown ` returns ` true ` if the value is present in the data resource.
240
- - ` isIANA ` returns ` true ` if the value is present in the Root Zone Database .
240
+ - ` isIANA ` returns ` true ` if the value is present in the IANA Top Level Domain List .
241
241
- ` isPublicSuffix ` returns ` true ` if the value is present in the Public Suffix List.
242
242
- ` isICANN ` returns ` true ` if the value is present in the Public Suffix List ICANN section.
243
243
- ` isPrivate ` returns ` true ` if the value is present in the Public Suffix List private section.
@@ -279,9 +279,9 @@ manipulating domain labels. You can access the object using the following method
279
279
280
280
~~~ php
281
281
<?php
282
- use Pdp\PublicSuffixList ;
282
+ use Pdp\Rules ;
283
283
284
- /** @var PublicSuffixList $publicSuffixList */
284
+ /** @var Rules $publicSuffixList */
285
285
$result = $publicSuffixList->resolve('www.bbc.co.uk');
286
286
$domain = $result->domain();
287
287
echo $domain->toString(); // display 'www.bbc.co.uk'
@@ -307,9 +307,9 @@ following methods:
307
307
308
308
~~~ php
309
309
<?php
310
- use Pdp\PublicSuffixList ;
310
+ use Pdp\Rules ;
311
311
312
- /** @var PublicSuffixList $publicSuffixList */
312
+ /** @var Rules $publicSuffixList */
313
313
$domain = $publicSuffixList->resolve('www.ExAmpLE.cOM')->domain();
314
314
315
315
$newDomain = $domain
@@ -353,9 +353,9 @@ IDNA Compatibility Processing. Domain objects expose a `toAscii` and a
353
353
354
354
~~~ php
355
355
<?php
356
- use Pdp\PublicSuffixList ;
356
+ use Pdp\Rules ;
357
357
358
- /** @var PublicSuffixList $publicSuffixList */
358
+ /** @var Rules $publicSuffixList */
359
359
$unicodeDomain = $publicSuffixList->resolve('bébé.be')->domain();
360
360
echo $unicodeDomain->toString(); // returns 'bébé.be'
361
361
@@ -416,15 +416,15 @@ nevertheless, the library comes bundle with a **optional service** which
416
416
enables resolving domain name without the constant network overhead of
417
417
continuously downloading the remote databases.
418
418
419
- The interfaces defined under the ` Pdp\Storage ` namespace enable
420
- integrating a database managing system and provide an implementation example
419
+ The interfaces and classes defined under the ` Pdp\Storage ` namespace enable
420
+ integrating a resource managing system and provide an implementation example
421
421
using PHP-FIG PSR interfaces.
422
422
423
423
#### Using PHP-FIG interfaces
424
424
425
425
The ` Pdp\Storage\PsrStorageFactory ` enables returning storage instances that
426
- retrieve, convert and cache the Public Suffix List and the IANA Root
427
- Zone Database using standard interfaces published by the PHP-FIG.
426
+ retrieve, convert and cache the Public Suffix List and the IANA Top Level
427
+ Domain List using standard interfaces published by the PHP-FIG.
428
428
429
429
To work as intended, the ` Pdp\Storage\PsrStorageFactory ` constructor requires:
430
430
@@ -465,7 +465,7 @@ For the purpose of this example we will use our PSR powered solution with:
465
465
We will cache both external sources for 24 hours in a PostgreSQL database.
466
466
467
467
You are free to use other libraries/solutions/settings as long as they
468
- implement the required PSR interfaces.
468
+ implement the required PSR interfaces.
469
469
470
470
~~~ php
471
471
<?php
@@ -496,7 +496,7 @@ $cachePrefix = 'pdp_';
496
496
$cacheTtl = new DateInterval('P1D');
497
497
$factory = new PsrStorageFactory($cache, $client, $requestFactory);
498
498
$pslStorage = $factory->createPublicSuffixListStorage($cachePrefix, $cacheTtl);
499
- $rzdStorage = $factory->createRootZoneDatabaseStorage ($cachePrefix, $cacheTtl);
499
+ $rzdStorage = $factory->createTopLevelDomainListStorage ($cachePrefix, $cacheTtl);
500
500
501
501
// if you need to force refreshing the rules
502
502
// before calling them (to use in a refresh script)
@@ -507,8 +507,8 @@ $publicSuffixList = $pslStorage->get(PsrStorageFactory::PUBLIC_SUFFIX_LIST_URI);
507
507
// if you need to force refreshing the rules
508
508
// before calling them (to use in a refresh script)
509
509
// uncomment this part or adapt it to you script logic
510
- // $rzdStorage->delete(PsrStorageFactory::ROOT_ZONE_DATABASE_URI );
511
- $rootZoneDatabase = $rzdStorage->get(PsrStorageFactory::ROOT_ZONE_DATABASE_URI );
510
+ // $rzdStorage->delete(PsrStorageFactory::TOP_LEVEL_DOMAIN_LIST_URI );
511
+ $topLevelDomains = $rzdStorage->get(PsrStorageFactory::TOP_LEVEL_DOMAIN_LIST_URI );
512
512
~~~
513
513
514
514
** Be sure to adapt the following code to your own application.
@@ -520,8 +520,8 @@ code in your application.**
520
520
521
521
### Automatic Updates
522
522
523
- It is important to always have an up to date Public Suffix List and Root Zone
524
- Database .
523
+ It is important to always have an up to date Public Suffix List and Top Level
524
+ Domain List .
525
525
This library no longer provide an out of the box script to do so as implementing
526
526
such a job heavily depends on your application setup.
527
527
You can use the above example script as a starting point to implement such a job.
0 commit comments