PHPackages                             handmadeweb/statamic-cloudflare - 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. [Caching](/categories/caching)
4. /
5. handmadeweb/statamic-cloudflare

ActiveLibrary[Caching](/categories/caching)

handmadeweb/statamic-cloudflare
===============================

2.1.0(1y ago)45.3k↓75%5[2 issues](https://github.com/HandmadeWeb/statamic-cloudflare/issues)[1 PRs](https://github.com/HandmadeWeb/statamic-cloudflare/pulls)MITPHPPHP ^8.0

Since Jul 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/HandmadeWeb/statamic-cloudflare)[ Packagist](https://packagist.org/packages/handmadeweb/statamic-cloudflare)[ RSS](/packages/handmadeweb-statamic-cloudflare/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (11)Used By (0)

[![MIT Licensed](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Cloudflare integration for Statamic with CLI, static caching integration and control panel integration.

Inspired by [sebdesign/artisan-cloudflare](https://github.com/sebdesign/artisan-cloudflare)

Requirements
------------

[](#requirements)

- Statamic 4.0.0 or higher

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

[](#installation)

You can install the package via composer:

```
composer require handmadeweb/statamic-cloudflare
```

#### Copy the package config to your local config with the publish command:

[](#copy-the-package-config-to-your-local-config-with-the-publish-command)

```
php artisan vendor:publish --provider="HandmadeWeb\StatamicCloudflare\ServiceProvider"
```

Then add your cloudflare details to your `.env` file.

```
CLOUDFLARE_KEY=
CLOUDFLARE_EMAIL=
```

or

```
CLOUDFLARE_TOKEN=
```

`Note that CLOUDFLARE_KEY will be used instead of CLOUDFLARE_TOKEN in the event that they are both set. KEY is the global api key with all possible permissions and TOKEN is a generated Api KEY/TOKEN which has specific permissions enabled/disabled.`

And configure your `zones`, If you only need to specify a single zone, then you can add it to your `.env`

```
CLOUDFLARE_ZONE_DOMAIN=
CLOUDFLARE_ZONE_ID=
```

Otherwise you can specify multiple zones in your `statamic-cloudflare.php`

```
    /*
     * Array of zones.
     *
     * Each zone must have its domain as the key. The value should be your zoneId.
     *
     * you can find your zoneId under 'Account Home > site > Api'.
     *
     * E.g.
     *
     * 'example.com' => '023e105f4ecef8ad9ca31a8372d0c353'
     */
    'zones' => [
        // env('CLOUDFLARE_ZONE_DOMAIN', null) => env('CLOUDFLARE_ZONE_ID', null),
    ],
```

By default all purge actions `except the Cli commands` will be queued with your default queue.

This can be changed in the configuration.

```
    /*
     * Should purges be processed in a queue?
     * CLI commands will always run on request.
     */
    'queued' => true,
```

Usage
-----

[](#usage)

### Cli

[](#cli)

You can purge everything via the following commands.

```
php artisan cloudflare:cache:purge:everything
```

```
php please cloudflare:cache:purge:everything
```

### Static Caching

[](#static-caching)

If you want to use `statamic-cloudflare` as a static cache strategy then you will need to manually register the cacher in the register method of your `App\Providers\AppServiceProvider` class.

```
/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    \HandmadeWeb\StatamicCloudflare\Cloudflare::registerCacher();
}
```

Then update your `static_cache` config.

```
'strategies' => [

    'half' => [
        'driver' => 'application',
        'expiry' => null,
    ],

    'full' => [
        'driver' => 'file',
        'path' => public_path('static'),
        'lock_hold_length' => 0,
    ],

    'cloudflare' => [
        'driver' => 'cloudflare',
        'strategy' => 'null',
    ],
],
```

Then update the `static_cache` strategy at the top of the configuration to:

```
'strategy' => 'cloudflare',
```

Currently the Cloudflare integration is only used for purging, If you would like to use another caching strategy in combination with this caching strategy, then you are free to do that.

This can be done by updating the `strategy` section within the `cloudflare` strategy, below is an example where we will be caching the application using the [half measure](https://statamic.dev/static-caching#application-driver)

```
'cloudflare' => [
    'driver' => 'cloudflare',
    'strategy' => 'half',
],
```

In theory, you should be able to use any caching strategy here, such as the [full measure](https://statamic.dev/static-caching#file-driver) or any other first or third party strategies, `statamic-cloudfare` will simply pass requests to the defined strategy and will just hook into the purge actions to also purge the page in Cloudflare.

### Control Panel

[](#control-panel)

#### Events

[](#events)

`statamic-cloudflare` will listen to the `Statamic\Events\EntrySaved`, `Statamic\Events\EntryDeleted`, `Statamic\Events\TermSaved` and `Statamic\Events\TermDeleted` events and will trigger a pruge for the url. These events will be ignored if you have configured the `static cache` to be a strategy that uses the `cloudflare` driver, as the driver will instead handle the needed purging actions.

#### Utility

[](#utility)

`statamic-cloudflare` will add a utility to your Statamic CP.

route: `/cp/utilities/cloudflare`

This will be available to `Super Users` and Users who have the ` Cloudflare Manager` permission.

You can purge everything quickly from here.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://statamic.com/addons/handmadeweb/statamic-cloudflare/release-notes) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/handmadeweb/statamic-cloudflare/blob/main/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Handmade Web &amp; Design](https://github.com/handmadeweb)
- [Michael Rook](https://github.com/michaelr0)
- [All Contributors](https://github.com/handmadeweb/statamic-cloudflare/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/handmadeweb/statamic-cloudflare/blob/main/LICENSE) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~135 days

Recently: every ~300 days

Total

10

Last Release

532d ago

Major Versions

1.0.7 → 2.0.02023-05-14

PHP version history (3 changes)1.0.0PHP ^7.3 || ^8.0

1.0.6PHP ^7.3||^8.0

2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e7a98568b1db97131b747177e0460eac0afd7e5bb47569243f9656f5da2bc4f?d=identicon)[HandmadeWeb](/maintainers/HandmadeWeb)

---

Top Contributors

[![michaelr0](https://avatars.githubusercontent.com/u/54159303?v=4)](https://github.com/michaelr0 "michaelr0 (5 commits)")[![jimblue](https://avatars.githubusercontent.com/u/10623367?v=4)](https://github.com/jimblue "jimblue (4 commits)")[![miteyema](https://avatars.githubusercontent.com/u/2599590?v=4)](https://github.com/miteyema "miteyema (1 commits)")

---

Tags

cloudflarestatamicStatamic addonstatamic-pluginstatamic-cache

### Embed Badge

![Health badge](/badges/handmadeweb-statamic-cloudflare/health.svg)

```
[![Health](https://phpackages.com/badges/handmadeweb-statamic-cloudflare/health.svg)](https://phpackages.com/packages/handmadeweb-statamic-cloudflare)
```

###  Alternatives

[yediyuz/laravel-cloudflare-cache

laravel-cloudflare-cache

28239.2k](/packages/yediyuz-laravel-cloudflare-cache)[nexxai/laravel-cfcache

A handful of Cloudflare cache helpers for Laravel

1317.7k](/packages/nexxai-laravel-cfcache)[steadlane/silverstripe-cloudflare

This module aims to relieve the stress of using Cloudflare caching with any SilverStripe project. Adds extension hooks that clears Cloudflare's cache for a specific page when that page is published or unpublished.

243.7k](/packages/steadlane-silverstripe-cloudflare)

PHPackages © 2026

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