nytris/dns

Maintainers

Details

github.com/nytris/dns

Source

Issues

Installs: 1 548

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:project

v0.0.1 2024-08-27 00:46 UTC

This package is auto-updated.

Last update: 2024-10-27 01:34:12 UTC


README

Build Status

Concise ReactPHP DNS config with caching.

Usage

Install this package with Composer:

$ composer require nytris/dns

When using Nytris platform (recommended)

Configure Nytris platform:

nytris.config.php

<?php

declare(strict_types=1);

use Nytris\Boot\BootConfig;
use Nytris\Boot\PlatformConfig;
use Nytris\Cache\Adapter\ReactCacheAdapter;
use Nytris\Dns\Dns;
use React\Socket\Connector;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$bootConfig = new BootConfig(new PlatformConfig(__DIR__ . '/var/cache/nytris/'));

$bootConfig->installPackage(new MyNytrisPackage(
    // Using Nytris Cache & Symfony Cache adapters as an example.
    connectorFactory: fn (string $cachePath) => new Connector([
        'dns' => (new Dns())->createResolver(
            new ReactCacheAdapter(
                new FilesystemAdapter(
                    'my_cache_key',
                    0,
                    $cachePath
                )
            )
        ),
    ])
));

return $bootConfig;