jeremykendall / php-domain-parser

Public Suffix List based domain parsing implemented in PHP
MIT License
1.16k stars 128 forks source link

Rewrite the documentation #275

Closed nyamsprod closed 3 years ago

nyamsprod commented 4 years ago

With a new major version it may be time to rewrite the documentation or move the documentation to a dedicated website so that both v5 and v6 documentation can live side by side.

umairkhan-dev commented 4 years ago

As per @nyamsprod's comment.

@umairkhan-dev thanks for the input. I would strongly advise you put this infos under #275 because indeed the rewrite aim at resolving these confusion and in the next major release I'm trying to resolve them at the API level. Those concept will be easier to grasp and to understand.

Quoting from #283

Some suggestions.

1. Kindly do briefly explain in documentation

  • what functions / properties of objects do. E.g. Like isResolvable() and isKnown() (common between Pdp\Domain and Pdp\PublicSuffix Objects).
  • and what their return or values means. E.g. What is meant by isResolvable or isKnown of Pdp\Domain if their value is true.

...

3. Please provide a single concise full example consisting of major parts of this parser. Like you insists upon setting some scenario to update PSL (or RZD) cache. Here is an example of my test usage.

require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor/autoload.php');
try {
    $manager = new \Pdp\Manager(new \Pdp\Cache(), new \Pdp\CurlHttpClient(), new DateInterval('P1D')); // Using Manager to make, refresh, update cache. new DateInterval('P1D') defines that cache is updated daily day.
    $rules = $manager->getRules(); //  Rules are fetched from cache and cache files are updated if needed as per DateInterval provide in Manager object creation.
    $domain = $rules->resolve('www.abc.enfield.sch.uk'); // Resolve provided domain and returns Pdp\Domain object.
    print_r($domain);
    var_dump($domain);
    var_dump($domain->getPublicSuffix()); // Returns PublicSuffix part of provided domain as string.
    // $ps = \Pdp\PublicSuffix::createFromDomain($domain); // Make and return Pdp\PublicSuffix object in reference to Pdp\Domain object.
    $ps = $rules->getPublicSuffix($domain); // Make and return Pdp\PublicSuffix object in reference to Pdp\Domain object.
    print_r($ps);
    var_dump($ps);
} catch (Exception $e) {
    var_dump($e);
}