You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once the PSL has been converted we can feed its data to a `Pdp\Rules` object which is responsible for resolving a given domain name against the PSL rules.
70
+
Once the PSL has been converted we can feed its data to a `Pdp\Rules` object which is responsable for resolving a given domain name against the PSL rules.
81
71
82
72
~~~php
83
73
<?php
@@ -95,7 +85,7 @@ final class Rules
95
85
}
96
86
~~~
97
87
98
-
The `Rules` constructor expects a `array` representation of the Public Suffix List. This `array` representation is constructed using the `Pdp\Converter` class.
88
+
The `Rules` constructor expects the result of the PSL conversion by the `Pdp\Converter` class.
99
89
100
90
Domain name resolution is done using the `Rules::resolve` method which returns a `Pdp\Domain` object. The method expects
101
91
@@ -105,9 +95,7 @@ Domain name resolution is done using the `Rules::resolve` method which returns a
105
95
-`Rules::ICANN_DOMAINS`, will validate the domain name againts the PSL ICANN section only.
106
96
-`Rules::PRIVATE_DOMAINS`, will validate the domain name againts the PSL PRIVATE section only.
107
97
108
-
By default, the full PSL is used.
109
-
110
-
An exception will be thrown if an undefined section is submitted otherwise, a `Pdp\Domain` object is returned.
98
+
By default, the `$type` argument equals `Rules::ALL_DOMAINS`. If an unrecognized section is submitted otherwise, a `Pdp\Exception` exception will be thrown.
111
99
112
100
~~~php
113
101
<?php
@@ -126,9 +114,6 @@ final class Domain implements JsonSerializable
126
114
127
115
The `Domain` getters method always return normalized value according to the domain status against the PSL rules.
128
116
129
-
**Warning:**`Domain::isKnown`, `Domain::isICANN` status depends on the PSL rules used.
130
-
For the same domain, depending on the rules used a domain public suffix status may be known or not, may be ICANN or not.
**Warning:** Some people use the PSL to determine what is a valid domain name and what isn't. This is dangerous, particularly in these days where new gTLDs are arriving at a rapid pace, if your software does not regularly receive PSL updates, it may erroneously think new gTLDs are not known. The DNS is the proper source for this information. If you must use it for this purpose, please do not bake static copies of the PSL into your software with no update mechanism.
163
+
**Warning: While the above example works it is highly discouraged to use the library in a productive application this way, without a caching mechanism to load the PSL.**
164
+
165
+
**Warning: `Domain::isKnown`, `Domain::isICANN` status depends on the PSL rules used. For the same domain, depending on the rules used a domain public suffix status may be known or not, may be ICANN or not.**
166
+
167
+
**Warning: Some people use the PSL to determine what is a valid domain name and what isn't. This is dangerous, particularly in these days where new gTLDs are arriving at a rapid pace, if your software does not regularly receive PSL updates, it may erroneously think new gTLDs are not known. The DNS is the proper source for this information. If you must use it for this purpose, please do not bake static copies of the PSL into your software with no update mechanism.**
175
168
176
169
### Public Suffix List Maintenance
177
170
178
-
**Directly fetching the Public Suffix List without caching the result is not recommend**. For that reason, the package comes bundle with a `Pdp\Manager` classwhich retrieves, converts and caches the Public Suffix List for you as well as create a `Pdp\Rules` object on demand.
171
+
**Directly fetching the PSL without caching the result is not recommend**. For that reason, the library comes bundle with a `Pdp\Manager` class. This class is a service which enables resolving domain name without the constant network overhead of continously downloading the PSL. The class retrieves, converts and caches the PSL as well as creates the corresponding `Pdp\Rules` object on demand. It uses internally a `Pdp\Converter` object to convert the fetched PSL into its `array` representation when required.
179
172
180
173
~~~php
181
174
<?php
@@ -202,8 +195,6 @@ To work as intended, the `Manager` constructor requires:
202
195
- a `HttpClient` interface which exposes the `HttpClient::getContent` method which expects a string URL representation has its sole argument and returns the body from the given URL resource as a string.
203
196
If an error occurs while retrieving such body a `HttpClientException` is thrown.
204
197
205
-
**Of note:** the class also uses internally a `Pdp\Converter` object to convert the fetched PSL into its `array` representation when required.
206
-
207
198
~~~php
208
199
<?php
209
200
@@ -246,6 +237,8 @@ The method takes an optional `$source_url` argument which specifies the PSL sour
246
237
247
238
On error, the method throws an `Pdp\Exception`.
248
239
240
+
**THIS IS THE RECOMMENDED WAY OF USING THE LIBRARY**
241
+
249
242
~~~php
250
243
<?php
251
244
@@ -254,13 +247,24 @@ use Pdp\CurlHttpClient;
254
247
use Pdp\Manager;
255
248
256
249
$manager = new Manager(new Cache(), new CurlHttpClient());
This method enables refreshing your local copy of the PSL stored with your [PSR-16](http://www.php-fig.org/psr/psr-16/) Cache and retrieved using the Http Client. By default the method will use the `Manager::PSL_URL` as the source URL but you are free to substitute this URL with your own.
267
+
The `Manager::refreshRules` method enables refreshing your local copy of the PSL stored with your [PSR-16](http://www.php-fig.org/psr/psr-16/) Cache and retrieved using the Http Client. By default the method will use the `Manager::PSL_URL` as the source URL but you are free to substitute this URL with your own.
264
268
The method returns a boolean value which is `true` on success.
265
269
266
270
~~~php
@@ -271,12 +275,17 @@ use Pdp\CurlHttpClient;
271
275
use Pdp\Manager;
272
276
273
277
$manager = new Manager(new Cache(), new CurlHttpClient());
It is important to always have an up to date PSL ICANN Section. In order to do so the library comes bundle with an auto-update script located in the `bin` directory.
288
+
It is important to always have an up to date PSL. In order to do so the library comes bundle with an auto-update script located in the `bin` directory.
280
289
281
290
~~~bash
282
291
$ php ./bin/update-psl
@@ -293,7 +302,7 @@ If you prefer using your own implementations you should:
293
302
1. Copy the `Pdp\Installer` class
294
303
2. Adapt its code to reflect your requirements.
295
304
296
-
In any cases your are required to update regularly your PSL information with your chosen script to keep your data up to date.
305
+
In any case, your are required to update regularly your PSL information with your chosen script to keep your data up to date.
0 commit comments