{"id":21588820,"url":"https://github.com/handmadeweb/statamic-cloudflare","last_synced_at":"2025-10-09T05:33:39.660Z","repository":{"id":62514386,"uuid":"390657654","full_name":"HandmadeWeb/statamic-cloudflare","owner":"HandmadeWeb","description":"Cloudflare integration for Statamic with CLI, static caching integration and control panel integration.","archived":false,"fork":false,"pushed_at":"2024-12-02T22:24:26.000Z","size":35,"stargazers_count":3,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T16:59:24.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HandmadeWeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-29T08:38:24.000Z","updated_at":"2024-12-02T22:20:04.000Z","dependencies_parsed_at":"2024-11-24T16:11:37.588Z","dependency_job_id":"7f9d2e69-671c-4d6a-98a6-f766fc1544b4","html_url":"https://github.com/HandmadeWeb/statamic-cloudflare","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.0625,"last_synced_commit":"19bd522ca92ac7a96da75172d1a40054ead712f8"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandmadeWeb%2Fstatamic-cloudflare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandmadeWeb%2Fstatamic-cloudflare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandmadeWeb%2Fstatamic-cloudflare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandmadeWeb%2Fstatamic-cloudflare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HandmadeWeb","download_url":"https://codeload.github.com/HandmadeWeb/statamic-cloudflare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248304898,"owners_count":21081544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T16:11:29.180Z","updated_at":"2025-10-09T05:33:34.606Z","avatar_url":"https://github.com/HandmadeWeb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.md)\n\nCloudflare integration for Statamic with CLI, static caching integration and control panel integration.\n\nInspired by [sebdesign/artisan-cloudflare](https://github.com/sebdesign/artisan-cloudflare)\n\n## Requirements\n\n* Statamic 4.0.0 or higher\n\n## Installation\n\nYou can install the package via composer:\n\n```shell\ncomposer require handmadeweb/statamic-cloudflare\n```\n\n#### Copy the package config to your local config with the publish command:\n\n```shell\nphp artisan vendor:publish --provider=\"HandmadeWeb\\StatamicCloudflare\\ServiceProvider\"\n```\n\nThen add your cloudflare details to your `.env` file.\n\n```env\nCLOUDFLARE_KEY=\nCLOUDFLARE_EMAIL=\n```\n\nor\n\n```env\nCLOUDFLARE_TOKEN=\n```\n\n`Note that CLOUDFLARE_KEY will be used instead of CLOUDFLARE_TOKEN in the event that they are both set.\nKEY is the global api key with all possible permissions and TOKEN is a generated Api KEY/TOKEN which has specific permissions enabled/disabled.`\n\nAnd configure your `zones`, If you only need to specify a single zone, then you can add it to your `.env`\n\n```env\nCLOUDFLARE_ZONE_DOMAIN=\nCLOUDFLARE_ZONE_ID=\n```\n\nOtherwise you can specify multiple zones in your `statamic-cloudflare.php`\n\n```php\n    /*\n     * Array of zones.\n     *\n     * Each zone must have its domain as the key. The value should be your zoneId.\n     *\n     * you can find your zoneId under 'Account Home \u003e site \u003e Api'.\n     *\n     * E.g.\n     *\n     * 'example.com' =\u003e '023e105f4ecef8ad9ca31a8372d0c353'\n     */\n    'zones' =\u003e [\n        // env('CLOUDFLARE_ZONE_DOMAIN', null) =\u003e env('CLOUDFLARE_ZONE_ID', null),\n    ],\n```\n\nBy default all purge actions `except the Cli commands` will be queued with your default queue.\n\nThis can be changed in the configuration.\n\n```php\n    /*\n     * Should purges be processed in a queue?\n     * CLI commands will always run on request.\n     */\n    'queued' =\u003e true,\n```\n\n## Usage\n\n### Cli\n\nYou can purge everything via the following commands.\n\n```shell\nphp artisan cloudflare:cache:purge:everything\n```\n\n```shell\nphp please cloudflare:cache:purge:everything\n```\n\n### Static Caching\n\nIf 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.\n\n```php\n/**\n * Register any application services.\n *\n * @return void\n */\npublic function register()\n{\n    \\HandmadeWeb\\StatamicCloudflare\\Cloudflare::registerCacher();\n}\n```\n\nThen update your `static_cache` config.\n\n```php\n'strategies' =\u003e [\n\n    'half' =\u003e [\n        'driver' =\u003e 'application',\n        'expiry' =\u003e null,\n    ],\n\n    'full' =\u003e [\n        'driver' =\u003e 'file',\n        'path' =\u003e public_path('static'),\n        'lock_hold_length' =\u003e 0,\n    ],\n\n    'cloudflare' =\u003e [\n        'driver' =\u003e 'cloudflare',\n        'strategy' =\u003e 'null',\n    ],\n],\n```\n\nThen update the `static_cache` strategy at the top of the configuration to:\n\n```php\n'strategy' =\u003e 'cloudflare',\n```\n\nCurrently 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.\n\nThis 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)\n\n```php\n'cloudflare' =\u003e [\n    'driver' =\u003e 'cloudflare',\n    'strategy' =\u003e 'half',\n],\n```\n\nIn 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.\n\n### Control Panel\n\n#### Events\n\n`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.\nThese 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.\n\n#### Utility\n\n`statamic-cloudflare` will add a utility to your Statamic CP.\n\nroute: `/cp/utilities/cloudflare`\n\nThis will be available to `Super Users` and Users who have the `\nCloudflare Manager` permission.\n\nYou can purge everything quickly from here.\n\n## Changelog\n\nPlease see [CHANGELOG](https://statamic.com/addons/handmadeweb/statamic-cloudflare/release-notes) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/handmadeweb/statamic-cloudflare/blob/main/CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Handmade Web \u0026 Design](https://github.com/handmadeweb)\n- [Michael Rook](https://github.com/michaelr0)\n- [All Contributors](https://github.com/handmadeweb/statamic-cloudflare/graphs/contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/handmadeweb/statamic-cloudflare/blob/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandmadeweb%2Fstatamic-cloudflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhandmadeweb%2Fstatamic-cloudflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandmadeweb%2Fstatamic-cloudflare/lists"}