nytris/dns

维护者

详细信息

github.com/nytris/dns

源代码

问题

安装: 442

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:项目

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

This package is auto-updated.

Last update: 2024-08-27 00:57:50 UTC


README

Build Status

简洁的带有缓存的ReactPHP DNS配置。

用法

使用Composer安装此包

$ composer require nytris/dns

当使用Nytris平台(推荐)时

配置Nytris平台

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;