mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: cloudflare purge command
This commit is contained in:
@@ -8,6 +8,9 @@ RGAPI_KEY="RGAPI-00000000-0000-0000-0000-000000000000"
|
|||||||
|
|
||||||
USER_AGENT="Heimerdinger/1.0 (Heimerdinger.lol) PHP"
|
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_CHANNEL=stack
|
||||||
LOG_DEPRECATIONS_CHANNEL=null
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
|
|||||||
46
app/Console/Commands/CloudflarePurgeCommand.php
Normal file
46
app/Console/Commands/CloudflarePurgeCommand.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
|
class CloudflarePurgeCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'cloudflare:purge';
|
||||||
|
|
||||||
|
protected $description = 'Purge the Cloudflare cache.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
$cf_zone_id = config('cloudflare.cf_zone_id');
|
||||||
|
$cf_auth_bearer = config('cloudflare.cf_auth_bearer');
|
||||||
|
|
||||||
|
$response = $client->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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'debug' => (bool) env('APP_DEBUG', false),
|
'debug' => (bool)env('APP_DEBUG', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
17
config/cloudflare.php
Normal file
17
config/cloudflare.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cloudflare Information
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These values are used to purge the Cloudflare cache when the application
|
||||||
|
| is updated. The zone ID can be found in the Cloudflare dashboard under
|
||||||
|
| the "Overview" tab. The bearer token can be generated in the "API" tab.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cf_zone_id' => env('CLOUDFLARE_ZONE_ID', '00000'),
|
||||||
|
'cf_auth_bearer' => env('CLOUDFLARE_AUTH_BEARER', '00000'),
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user