PHPackages                             tourze/cloudflare-dns-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/cloudflare-dns-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/cloudflare-dns-bundle
============================

Cloudflare DNS Manage

0.1.3(5mo ago)131MITPHPCI passing

Since Apr 10Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/tourze/cloudflare-dns-bundle)[ Packagist](https://packagist.org/packages/tourze/cloudflare-dns-bundle)[ RSS](/packages/tourze-cloudflare-dns-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (44)Versions (8)Used By (0)

Cloudflare DNS Bundle
=====================

[](#cloudflare-dns-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/22a8b1af1d609449ebb6c8c635c6a7bb895f84aa4975742c2c8a46e5c435f757/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f636c6f7564666c6172652d646e732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/cloudflare-dns-bundle)[![PHP Version](https://camo.githubusercontent.com/00dc9a9018e0821948e58c7ae233eeecb6fde493346daec560639cdad44e3441/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f636c6f7564666c6172652d646e732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/cloudflare-dns-bundle)[![License](https://camo.githubusercontent.com/b48c3ae27332bf117b28f9603d95a7f0fe215f785bba465b92d952a68c562212/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f636c6f7564666c6172652d646e732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/cloudflare-dns-bundle)[![Code Coverage](https://camo.githubusercontent.com/73ee3bab50824f778cedc6b4b3f78bcdab621eef812a979ec388b8ad692a4bff/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/php-monorepo)[![Total Downloads](https://camo.githubusercontent.com/addccef968b8f74568b0cc2790e3667c41a2c0a49e9f9b7054867ef0108501f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f636c6f7564666c6172652d646e732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/cloudflare-dns-bundle)

A comprehensive Symfony bundle for managing Cloudflare DNS records, domains, and analytics with full ORM support, CLI tools, and EasyAdmin integration.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
    - [1. Add IAM Key](#1-add-iam-key)
    - [2. Sync Domains](#2-sync-domains)
    - [3. Manage DNS Records](#3-manage-dns-records)
    - [4. Analytics](#4-analytics)
- [Service Usage](#service-usage)
- [Entities](#entities)
- [CLI Commands](#cli-commands)
- [Admin Interface](#admin-interface)
- [Event System](#event-system)
- [Advanced Features](#advanced-features)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **Complete DNS Management**: Create, update, delete, and sync DNS records with Cloudflare API
- **Domain Synchronization**: Sync domains between Cloudflare and local database
- **Analytics Integration**: Fetch and store DNS query analytics data
- **Multi-Account Support**: Manage multiple Cloudflare accounts with IAM key management
- **EasyAdmin Integration**: Full CRUD operations with admin UI
- **Batch Operations**: Support for bulk DNS record operations
- **CLI Tools**: Comprehensive command-line tools for all operations
- **Event System**: Pre/post sync events for custom business logic
- **Audit Trail**: Automatic tracking of created/updated timestamps

Installation
------------

[](#installation)

### Requirements

[](#requirements)

- PHP &gt;= 8.1
- Symfony &gt;= 7.3
- Doctrine ORM &gt;= 3.0
- Cloudflare account with API credentials

### Install via Composer

[](#install-via-composer)

```
composer require tourze/cloudflare-dns-bundle
```

Configuration
-------------

[](#configuration)

### Bundle Registration

[](#bundle-registration)

The bundle and its dependencies will be automatically registered if using Symfony Flex. Otherwise, add to your `config/bundles.php`:

```
// config/bundles.php
return [
    // Dependencies (auto-registered via BundleDependencyInterface)
    Tourze\DoctrineTimestampBundle\DoctrineTimestampBundle::class => ['all' => true],
    Tourze\DoctrineUserBundle\DoctrineUserBundle::class => ['all' => true],
    Tourze\DoctrineTrackBundle\DoctrineTrackBundle::class => ['all' => true],
    Tourze\DoctrineIndexedBundle\DoctrineIndexedBundle::class => ['all' => true],
    // Main bundle
    CloudflareDnsBundle\CloudflareDnsBundle::class => ['all' => true],
];
```

### Database Setup

[](#database-setup)

1. Update your database schema:

```
php bin/console doctrine:schema:update --force
```

2. Load initial data fixtures (optional):

```
php bin/console doctrine:fixtures:load --group=cf
```

Quick Start
-----------

[](#quick-start)

### 1. Add IAM Key

[](#1-add-iam-key)

First, add your Cloudflare API credentials to the database:

```
use CloudflareDnsBundle\Entity\IamKey;

$iamKey = new IamKey();
$iamKey->setName('Main Account');
$iamKey->setEmail('your@email.com');
$iamKey->setAccessKey('your-api-key');
$iamKey->setAccountId('your-account-id');

$entityManager->persist($iamKey);
$entityManager->flush();
```

### 2. Sync Domains

[](#2-sync-domains)

```
# Sync all domains from Cloudflare
php bin/console cloudflare:sync-domains

# Sync specific domain
php bin/console cloudflare:sync-domains  --domain=example.com
```

### 3. Manage DNS Records

[](#3-manage-dns-records)

```
# Sync DNS records from Cloudflare to local DB
php bin/console cloudflare:sync-domain-record-to-local

# Sync DNS records from local DB to Cloudflare
php bin/console cloudflare:sync-dns-domain-record-to-remote

# Sync all DNS records for a domain
php bin/console cloudflare:sync-dns-domain-record-to-remote --all --domain=
```

### 4. Analytics

[](#4-analytics)

```
# Sync DNS analytics for last 24 hours
php bin/console cloudflare:sync-dns-analytics

# Sync analytics for specific time range
php bin/console cloudflare:sync-dns-analytics --since="2024-01-01" --until="2024-01-31"
```

Service Usage
-------------

[](#service-usage)

### DNS Record Service

[](#dns-record-service)

```
use CloudflareDnsBundle\Service\DnsRecordService;
use CloudflareDnsBundle\Entity\DnsRecord;
use CloudflareDnsBundle\Enum\DnsRecordType;

class MyService
{
    public function __construct(
        private DnsRecordService $dnsRecordService
    ) {}

    public function createRecord(): void
    {
        $record = new DnsRecord();
        $record->setDomain($domain);
        $record->setType(DnsRecordType::A);
        $record->setRecord('subdomain.example.com');
        $record->setContent('192.168.1.1');
        $record->setTtl(3600);
        $record->setProxy(true);

        $this->dnsRecordService->syncToRemote($record);
    }
}
```

### Domain Service

[](#domain-service)

```
use CloudflareDnsBundle\Service\DnsDomainService;

$domains = $dnsDomainService->syncFromRemote($iamKey);
foreach ($domains as $domain) {
    echo $domain->getName() . ' - ' . $domain->getStatus()->value . PHP_EOL;
}
```

Entities
--------

[](#entities)

### DnsDomain

[](#dnsdomain)

Represents a domain managed in Cloudflare:

- `name`: Domain name (e.g., example.com)
- `zoneId`: Cloudflare Zone ID
- `status`: Domain status (active, pending, etc.)
- `iamKey`: Associated IAM key

### DnsRecord

[](#dnsrecord)

Represents a DNS record:

- `domain`: Associated domain
- `type`: Record type (A, AAAA, CNAME, MX, TXT, NS, URI)
- `record`: Full record name
- `content`: Record value
- `ttl`: Time to live
- `proxy`: Whether Cloudflare proxy is enabled
- `recordId`: Cloudflare record ID

### IamKey

[](#iamkey)

Stores Cloudflare API credentials:

- `name`: Descriptive name
- `email`: Cloudflare account email
- `accessKey`: API key
- `accountId`: Cloudflare account ID

### DnsAnalytics

[](#dnsanalytics)

Stores DNS query analytics:

- `domain`: Associated domain
- `queryCount`: Number of queries
- `queryName`: Queried hostname
- `queryType`: DNS query type
- `responseCode`: DNS response code
- `datetime`: Analytics timestamp

CLI Commands
------------

[](#cli-commands)

CommandDescription`cloudflare:sync-domains`Sync domains from Cloudflare`cloudflare:sync-domain-info`Update domain zone information`cloudflare:sync-domain-record-to-local`Sync DNS records from Cloudflare to local DB`cloudflare:sync-dns-domain-record-to-remote`Sync DNS records from local DB to Cloudflare`cloudflare:sync-dns-analytics`Sync DNS analytics dataAdmin Interface
---------------

[](#admin-interface)

The bundle provides EasyAdmin CRUD controllers for all entities:

- **DnsDomainCrudController**: Manage domains
- **DnsRecordCrudController**: Manage DNS records
- **IamKeyCrudController**: Manage API credentials
- **DnsAnalyticsCrudController**: View analytics data

Access via your EasyAdmin dashboard configuration.

Event System
------------

[](#event-system)

The bundle dispatches events during sync operations:

```
use CloudflareDnsBundle\EventListener\DnsRecordSyncListener;
use Doctrine\ORM\Events;

class MyListener
{
    public function postPersist($args): void
    {
        $entity = $args->getObject();
        if ($entity instanceof DnsRecord) {
            // Custom logic after DNS record creation
        }
    }
}
```

Advanced Features
-----------------

[](#advanced-features)

### Batch Operations

[](#batch-operations)

The bundle supports batch operations via the Cloudflare API:

```
use CloudflareDnsBundle\Client\CloudflareHttpClient;

$operations = [
    'posts' => [$newRecord1, $newRecord2],
    'puts' => [['id' => $recordId, 'record' => $updatedRecord]],
    'deletes' => [$recordIdToDelete]
];

$client->batchDnsRecords($zoneId, $operations);
```

### Message Queue Integration

[](#message-queue-integration)

Async operations are supported via Symfony Messenger:

- `SyncDnsDomainsFromRemoteMessage`: Async domain sync
- `SyncDnsRecordToRemoteMessage`: Async DNS record sync

### Service Layer Architecture

[](#service-layer-architecture)

- **BaseCloudflareService**: Abstract base for all services
- **DomainSynchronizer**: Handles single domain sync
- **DomainBatchSynchronizer**: Handles bulk domain operations
- **CloudflareHttpClient**: Low-level API client with logging

Testing
-------

[](#testing)

The bundle includes comprehensive test coverage:

```
# Run all tests
vendor/bin/phpunit

# Run specific test suite
vendor/bin/phpunit tests/Service/

# Run with coverage
vendor/bin/phpunit --coverage-html coverage/
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please:

1. Follow PSR-12 coding standards
2. Add tests for new features
3. Update documentation as needed
4. Submit a pull request

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for more information.

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance77

Regular maintenance activity

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~47 days

Total

7

Last Release

179d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-cloudflare-dns-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-cloudflare-dns-bundle/health.svg)](https://phpackages.com/packages/tourze-cloudflare-dns-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M151](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
