定制 davidnsai/ionos-dns-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

davidnsai/ionos-dns-api-client

Composer 安装命令:

composer require davidnsai/ionos-dns-api-client

包简介

A PHP client library for the IONOS DNS API, providing easy management of DNS zones, records, and Dynamic DNS configurations.

README 文档

README

A PHP client library for the IONOS DNS API, providing easy management of DNS zones, records, and Dynamic DNS configurations.

PHP Version License

Installation

Install the package via Composer:

composer require ionos/dns-api-client

Requirements

  • PHP 8.1 or higher
  • cURL extension
  • JSON extension

Quick Start

<?php
require_once 'vendor/autoload.php';

use DNSApi\DNSApiClient;
use DNSApi\DNSApiException;

// Initialize the client
$dnsClient = new DNSApiClient('your-api-key-here');

try {
    // Get all zones
    $zones = $dnsClient->getZones();
    echo "Found " . count($zones) . " zones\n";
    
    // Create a new A record
    $record = $dnsClient->createRecord('www.example.com', 'A', '192.168.1.1', 3600);
    $createdRecords = $dnsClient->createRecords('zone-id-here', [$record]);
    
} catch (DNSApiException $e) {
    echo "DNS API Error: " . $e->getMessage() . "\n";
}

Features

  • Zone Management: List, get, update, and patch DNS zones
  • Record Management: Create, read, update, and delete DNS records
  • Dynamic DNS: Activate, update, and manage Dynamic DNS configurations
  • Type Safety: Built-in validation for DNS record types
  • Error Handling: Comprehensive exception handling with detailed error information
  • PSR-4 Autoloading: Follows PHP-FIG standards
  • Extensible: Injectable HTTP client interface for custom implementations

Supported DNS Record Types

The client supports all major DNS record types:

  • A, AAAA, CNAME, MX, NS, SOA, SRV, TXT
  • CAA, TLSA, SMIMEA, SSHFP, DS
  • HTTPS, SVCB, CERT, URI, RP, LOC, OPENPGPKEY

Usage Examples

Zone Operations

// Get all zones
$zones = $dnsClient->getZones();

// Get a specific zone with optional filters
$zone = $dnsClient->getZone('zone-id', [
    'recordType' => 'A',
    'recordName' => 'www'
]);

// Update entire zone (replaces all records)
$records = [
    $dnsClient->createRecord('www.example.com', 'A', '192.168.1.1'),
    $dnsClient->createRecord('mail.example.com', 'A', '192.168.1.2')
];
$dnsClient->updateZone('zone-id', $records);

// Patch zone (replaces records of same name and type)
$dnsClient->patchZone('zone-id', $records);

Record Operations

// Create multiple records
$records = [
    $dnsClient->createRecord('www.example.com', 'A', '192.168.1.1'),
    $dnsClient->createRecord('example.com', 'MX', 'mail.example.com', 3600, 10)
];
$createdRecords = $dnsClient->createRecords('zone-id', $records);

// Get a specific record
$record = $dnsClient->getRecord('zone-id', 'record-id');

// Update a record
$updatedRecord = $dnsClient->updateRecord('zone-id', 'record-id', [
    'content' => '192.168.1.100',
    'ttl' => 7200
]);

// Delete a record
$dnsClient->deleteRecord('zone-id', 'record-id');

Dynamic DNS

// Activate Dynamic DNS
$dynamicDns = $dnsClient->activateDynamicDNS(
    ['example.com', 'www.example.com'], 
    'My Dynamic DNS Configuration'
);
echo "Update URL: " . $dynamicDns->updateUrl . "\n";

// Update Dynamic DNS configuration
$dnsClient->updateDynamicDNS('bulk-id', ['newdomain.com'], 'Updated config');

// Delete specific Dynamic DNS configuration
$dnsClient->deleteDynamicDNS('bulk-id');

// Disable all Dynamic DNS
$dnsClient->disableDynamicDNS();

Custom HTTP Client

You can inject your own HTTP client implementation:

use DNSApi\HttpClientInterface;

class MyHttpClient implements HttpClientInterface
{
    public function request($method, $url, $options = [])
    {
        // Your custom HTTP implementation
        // Must return ['status_code' => int, 'body' => string]
    }
}

$dnsClient = new DNSApiClient('api-key', 'https://api.hosting.ionos.com/dns', new MyHttpClient());

Error Handling

The client throws DNSApiException for API errors:

try {
    $zones = $dnsClient->getZones();
} catch (DNSApiException $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "HTTP Code: " . $e->getCode() . "\n";
    
    // Get detailed error information
    $errors = $e->getErrors();
    if ($errors) {
        print_r($errors);
    }
}

Development

Running Tests

composer test

Code Style

Check code style:

composer cs-check

Fix code style:

composer cs-fix

Static Analysis

composer analyse

API Documentation

For complete API documentation, visit the IONOS DNS API Documentation.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Changelog

See CHANGELOG.md for a list of changes and releases.

davidnsai/ionos-dns-api-client 适用场景与选型建议

davidnsai/ionos-dns-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「client」 「dns」 「domain」 「hosting」 「records」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 davidnsai/ionos-dns-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 davidnsai/ionos-dns-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 davidnsai/ionos-dns-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-23