承接 artem-baranovskyi/dns-lookup 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

artem-baranovskyi/dns-lookup

最新稳定版本:1.0.3

Composer 安装命令:

composer require artem-baranovskyi/dns-lookup

包简介

This test standalone Laravel library allows to get all DNS records for the specified domain name.

README 文档

README

The DnsLookup library is a PHP package that provides DNS lookup functionality. It allows you to retrieve DNS records for a given domain name in various output formats.

Requirements & Dependencies

"php": "^8.2",
"monolog/monolog": "^3.0"

Installation

You can install the library using Composer. Run the following command in your project directory:

composer require artem-baranovskyi/dns-lookup

Then add package Service Provider to autoload in config/app.php:

        /*
         * Package Service Providers...
         */
        DnsLookupServiceProvider::class,

Also add package alias at Class Aliases section:

    'aliases' => Facade::defaultAliases()->merge([
        'DnsLookup' => ArtemBaranovskyi\DnsLookup\Facades\DnsLookupFacade::class,
    ])->toArray(),

Usage

To use the DnsLookup library, you can follow these options:

  1. Use DnsLookup as a facade, providing desired output format:
use ArtemBaranovskyi\DnsLookup\Facades\DnsLookupFacade;
...
    $domain = 'example.com';
    $dnsRecords = DnsLookupFacade::getDnsRecords($domain, 'array'); // use any from 'array', 'collection', 'json'
    dd($dnsRecords);
  1. Get an instance of DnsLookup form Service Container, providing desired output format:
use ArtemBaranovskyi\DnsLookup\Facades\DnsLookupFacade;

    $domain = 'example.com';
    $dnsLookup = app(DnsLookup::class);
    $dnsRecords = $dnsLookup->getDnsRecords($domain, 'array'); // use any from 'array', 'collection', 'json'
    dd($dnsRecords);

Available Output Formats

The getDnsRecords method accepts a format parameter, which determines the output format of the DNS records. The following formats are supported:

array: Returns an array of DNS records (default format)
collection: Returns a DnsRecordCollection object containing the DNS records.
json: Returns a JSON-encoded string of the DNS records.

Error Handling

If an error occurs during the DNS lookup process, an Exception will be thrown with an error message. It's recommended to wrap the getDnsRecords call in a try-catch block to handle any potential exceptions:

try {
    $dnsRecords = $dnsLookup->getDnsRecords($domain, $format);
    // Use the DNS records
} catch (Exception $e) {
    echo "An error occurred: " . $e->getMessage();
}

Contributing

Contributions to the DnsLookup library are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on GitHub.

License

This library is open source and licensed under the MIT License.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-21