diff --git a/.env.example b/.env.example index 1be5223..9a94cb8 100644 --- a/.env.example +++ b/.env.example @@ -8,6 +8,9 @@ RGAPI_KEY="RGAPI-00000000-0000-0000-0000-000000000000" USER_AGENT="Heimerdinger/1.0 (Heimerdinger.lol) PHP" +CLOUDFLARE_ZONE_ID="YOUR_CLOUDFLARE_ZONE" +CLOUDFLARE_AUTH_BEARER="YOUR_CLOUDFLARE_AUTH_BEARER" + LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug diff --git a/app/Console/Commands/CloudflarePurgeCommand.php b/app/Console/Commands/CloudflarePurgeCommand.php new file mode 100644 index 0000000..1e1257d --- /dev/null +++ b/app/Console/Commands/CloudflarePurgeCommand.php @@ -0,0 +1,46 @@ +request( + 'POST', + "https://api.cloudflare.com/client/v4/zones/" . $cf_zone_id . "/purge_cache", + [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $cf_auth_bearer, + 'Content-Type' => 'application/json', + ], + 'json' => [ + 'purge_everything' => true, + ], + ] + ); + + $body = json_decode($response->getBody(), true); + + if ($body['success'] === true) { + $this->info('Cloudflare cache purged successfully.'); + } else { + $this->error('Cloudflare cache could not be purged.'); + } + } +} diff --git a/config/app.php b/config/app.php index 4c231b4..69942df 100644 --- a/config/app.php +++ b/config/app.php @@ -42,7 +42,7 @@ return [ | */ - 'debug' => (bool) env('APP_DEBUG', false), + 'debug' => (bool)env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- diff --git a/config/cloudflare.php b/config/cloudflare.php new file mode 100644 index 0000000..9c0e1d4 --- /dev/null +++ b/config/cloudflare.php @@ -0,0 +1,17 @@ + env('CLOUDFLARE_ZONE_ID', '00000'), + 'cf_auth_bearer' => env('CLOUDFLARE_AUTH_BEARER', '00000'), +];