jeremykendall / php-domain-parser

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

Need help for upgrading - How to cache? #311

Closed pmochine closed 3 years ago

pmochine commented 3 years ago

I'm really sorry and I never did this before, but I'm asking here for help. Since version 6.0.0 everything has changed dramatically.

Here is my wrapper that I have used to extract the "RegistrableDomain" in version 5.7.2.

<?php

namespace Pmochine\LaravelTongue\Misc;

use Pdp\Cache;
use Pdp\CurlHttpClient;
use Pdp\Domain;
use Pdp\Manager;

/**
 * Small wrapper for getting the getRegistrableDomain.
 */
class DomainParser
{
    /** @var Pdp\Rules */
    protected $rules;

    public function __construct()
    {
        $manager = new Manager(new Cache(), new CurlHttpClient());
        $this->rules = $manager->getRules();
    }

    /**
     * https://github.com/jeremykendall/php-domain-parser.
     *
     * @param   string  $url
     *
     * @return  Domain
     */
    public function resolve(string $url): Domain
    {
        return $this->rules->resolve($url);
    }
}

Now I'm really lost and I don't know how to update this. Could any help me? You can find the code here (https://github.com/pmochine/Laravel-Tongue/blob/master/src/Misc/DomainParser.php)

nyamsprod commented 3 years ago

@pmochine thanks for using the library and indeed there was a change in how to cache the external resources in v6. To be honest In your position I would either:

pmochine commented 3 years ago

@nyamsprod thanks for the super fast reply. As for the Service Provider you mean the section of THIS IS THE RECOMMENDED WAY OF USING THE LIBRARY? I have to say, this is not an easy transition 😅 However, thanks for the hint of laravel-domain-parser. This could be helpful :)