tourze/ddns-bundle
最新稳定版本:0.1.0
Composer 安装命令:
composer require tourze/ddns-bundle
包简介
DDNS动态域名解析服务模块
README 文档
README
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:
- Checks if the entity contains DDNS attributes
- Extracts domain and IP address information
- 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:
- Iterate through all IP resolvers to get domain and IP mappings that need updating
- Check if each DNS provider supports the domain
- 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 processorDDNSUpdateService: DDNS update serviceDDNSEntityListener: Entity change listener
Examples
See examples/ExampleEntity.php for a complete usage example.
How It Works
- Attribute Marking: Use
#[DDNSDomain]and#[DdnsIp]attributes on entity fields - Event Listening: Doctrine event listeners monitor entity creation and update events
- Attribute Parsing: Attribute processor extracts field values with DDNS attributes
- DNS Updates: Calls DNS provider interfaces to update DNS records
Contributing
Contributions are welcome! Please follow these guidelines:
- Issues: Report bugs or suggest features via GitHub Issues
- Pull Requests: Fork the repository and submit PRs with clear descriptions
- Code Style: Follow PSR-12 coding standards
- Testing: Ensure all tests pass and add tests for new features
- 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
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-03