tourze / ddns-bundle
DDNS动态域名解析服务模块
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/ddns-bundle
Requires
- php: ^8.1
- doctrine/collections: ^2.3
- doctrine/data-fixtures: ^2.0
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/doctrine-fixtures-bundle: ^4.0
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/access-token-bundle: 0.0.*
- tourze/biz-user-bundle: 0.0.*
- tourze/bundle-dependency: 0.0.*
- tourze/ddns-contracts: 0.0.*
- tourze/json-rpc-lock-bundle: 0.1.*
- tourze/symfony-cron-job-bundle: 0.1.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-10-31 19:54:33 UTC
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.