PHP code example of nexxai / laravel-cfcache
1. Go to this page and download the library: Download nexxai/laravel-cfcache library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nexxai / laravel-cfcache example snippets
return [
'api' => [
'token' => env('CFCACHE_API_TOKEN'),
'zone_id' => env('CFCACHE_ZONE_ID'),
'settings' => [
'base_url' => env('CFCACHE_API_BASE_URL', 'https://api.cloudflare.com/client/v4'),
'timeout' => env('CFCACHE_API_TIMEOUT', 30),
'retry_attempts' => env('CFCACHE_API_RETRY_ATTEMPTS', 3),
'retry_delay' => env('CFCACHE_API_RETRY_DELAY', 1000),
],
],
'scheduled_purges' => [
'file' => env('CFCACHE_SCHEDULED_PURGES_FILE', storage_path('app/laravel-cfcache/scheduled-purges.json')),
],
'features' => [
'waf' => [
'rule_identifier' => env('CFCACHE_RULE_ID', 'laravel-waf-rule'),
'rule_description' => env('CFCACHE_RULE_DESCRIPTION', 'Valid Laravel Routes'),
'rule_action' => env('CFCACHE_RULE_ACTION', 'block'),
'hostnames' => env('CFCACHE_RULE_HOSTNAMES') ? array_filter(array_map('trim', explode(',', env('CFCACHE_RULE_HOSTNAMES')))) : [],
'ignorable_paths' => ['/_dusk/*'],
'forced_allowed_paths' => [],
],
],
];
'ignorable_paths' => [
'/_dusk/*', // Laravel Dusk testing routes
'/admin/test', // Specific test routes
'/debug/*', // Debug routes
],
'forced_allowed_paths' => [
'/cdn-cgi/zaraz/s.js', // Cloudflare Zaraz
'/cdn-cgi/monitor/xhr', // Optional: other edge-injected paths
],
// config/cfcache.php — rule applies only when Host matches one of these
'hostnames' => ['app.example.com', 'www.example.com'],
use Illuminate\Support\Facades\Schedule;
use JTSmith\Cloudflare\Support\ScheduledPurgeStore;
Schedule::call(fn (ScheduledPurgeStore $store) => $store->runDue())
->name('cloudflare-scheduled-cache-purges')
->everyMinute()
->withoutOverlapping();
sh
php artisan vendor:publish --tag=cfcache-config
sh
php artisan cloudflare:waf-rule
sh
php artisan cloudflare:waf-rule --sync
sh
# Schedule specific paths
php artisan cloudflare:purge /about /contact --schedule="2026-06-03 10:00:00"
# Schedule route-based purges
php artisan cloudflare:purge --route=home --route=users.index --schedule="tomorrow 02:00"
# Schedule a full cache purge
php artisan cloudflare:purge --all --force --schedule="2026-06-03 10:00:00"
# Schedule a prefix purge
php artisan cloudflare:purge --prefix=www.example.com/ --schedule="2026-06-03 10:00:00"