承接 tourze/ddns-bundle 相关项目开发

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

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

tourze/ddns-bundle

最新稳定版本:0.1.0

Composer 安装命令:

composer require tourze/ddns-bundle

包简介

DDNS动态域名解析服务模块

README 文档

README

Latest Version PHP Version License Total Downloads

English | 中文

DDNS (Dynamic DNS) service bundle for Symfony applications.

Features

  • Automatic DNS Updates: Automatically updates DNS records when entities are modified
  • Attribute-Based Configuration: Use PHP 8 attributes to mark domain and IP fields
  • Provider Agnostic: Support for multiple DNS providers through interfaces
  • Console Commands: Manual and scheduled DNS updates
  • Doctrine Integration: Seamless integration with Doctrine ORM events

Installation

composer require tourze/ddns-bundle

Dependencies

  • PHP 8.1 or higher
  • Symfony 6.4 or higher
  • Doctrine ORM

Quick Start

1. Register the Bundle

// config/bundles.php
return [
    // ...
    DDNSBundle\DDNSBundle::class => ['all' => true],
];

Usage

Using DDNS Attributes

Use #[DDNSDomain] and #[DdnsIp] attributes to mark domain and IP fields in your entities:

<?php

use DDNSBundle\Attribute\DDNSDomain;
use DDNSBundle\Attribute\DdnsIp;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class ServerNode
{
    #[ORM\Column(type: 'string')]
    #[DDNSDomain(provider: 'cloudflare')]
    private string $domain;

    #[ORM\Column(type: 'string')]
    #[DdnsIp(provider: 'cloudflare')]
    private string $ipAddress;

    // ... other fields and methods
}

Advanced Usage

Automatic DDNS Updates

When entities are created or updated, the system automatically:

  1. Checks if the entity contains DDNS attributes
  2. Extracts domain and IP address information
  3. Calls the corresponding DNS provider to update DNS records

Attribute Parameters

  • provider: Optional parameter to specify the DNS provider (e.g., 'cloudflare', 'aliyun', etc.)

Console Commands

ddns:provider:run

Runs DDNS provider update tasks. This command will:

  1. Iterate through all IP resolvers to get domain and IP mappings that need updating
  2. Check if each DNS provider supports the domain
  3. Update the corresponding DNS records
# Manually run DDNS update
php bin/console ddns:provider:run

This command is configured as a cron task and runs automatically every minute.

Configuration

The bundle automatically registers the following services:

  • DDNSAttributeProcessor: Attribute processor
  • DDNSUpdateService: DDNS update service
  • DDNSEntityListener: Entity change listener

Examples

See examples/ExampleEntity.php for a complete usage example.

How It Works

  1. Attribute Marking: Use #[DDNSDomain] and #[DdnsIp] attributes on entity fields
  2. Event Listening: Doctrine event listeners monitor entity creation and update events
  3. Attribute Parsing: Attribute processor extracts field values with DDNS attributes
  4. DNS Updates: Calls DNS provider interfaces to update DNS records

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Issues: Report bugs or suggest features via GitHub Issues
  2. Pull Requests: Fork the repository and submit PRs with clear descriptions
  3. Code Style: Follow PSR-12 coding standards
  4. Testing: Ensure all tests pass and add tests for new features
  5. Documentation: Update documentation for any changes

References

Changelog

See CHANGELOG.md for details on version history and updates.

License

This bundle is licensed under the MIT License. See the LICENSE file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-03