illuma-law / laravel-edge-clear
Standalone Cloudflare cache purging for Laravel
v1.0.0
2026-10-23 14:00 UTC
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0||^13.0
- illuminate/http: ^11.0||^12.0||^13.0
- illuminate/support: ^11.0||^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- mrpunyapal/peststan: ^0.2.12
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^9.0||^10.1||^11.3
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Purge Cloudflare cache and set edge-cache headers from a Laravel application.
Requires PHP 8.3+ and Laravel 11, 12, or 13.
Install and configure
composer require illuma-law/laravel-edge-clear php artisan vendor:publish --tag=edge-clear-config
Set your Cloudflare zone and API token in .env:
CLOUDFLARE_ZONE_ID=your-zone-id CLOUDFLARE_API_TOKEN=your-api-token
Purging is enabled only in production by default. Set
EDGE_CLEAR_ONLY_IN_PRODUCTION=false to enable it in other environments.
Never use real credentials in local or test environments.
Purge cache
use IllumaLaw\EdgeClear\Facades\CloudflarePurger; CloudflarePurger::purgeByUrls([ 'https://example.com/posts/hello', 'https://example.com/posts', ]);
You can also purge by tags or clear the whole zone:
CloudflarePurger::purgeByTags(['posts', 'news']); CloudflarePurger::purgeEverything();
The SetEdgeCacheHeaders middleware adds cache headers to successful GET
responses. The optional BypassEdgeCache middleware disables caching for a
route:
use IllumaLaw\EdgeClear\Middleware\BypassEdgeCache; use IllumaLaw\EdgeClear\Middleware\SetEdgeCacheHeaders; Route::get('/posts', PostsController::class) ->middleware(SetEdgeCacheHeaders::class.':600;posts'); Route::get('/account', AccountController::class) ->middleware(BypassEdgeCache::class);
Test
composer test
composer analyse
vendor/bin/pint --test
MIT licensed. See LICENSE.
